As your business grows, your system may become increasingly complex. It becomes crucial and challenging to be able to track requests correctly.

Embeded image

OpenResty Edge makes things a little easier by enabling requests to be identified with a unique ID. It is our topic today: Request ID.

Embeded image

Global configuration Request ID

Let’s go to the OpenResty Edge’s Admin web console. It is our sample deployment of the console. Every user has her local deployment.

Screenshot

Now go to the global config page. Here you can configure whether you add a Request ID to the header of all requests.

Screenshot

Screenshot

This configuration item is on by default, which means that each request will have a Req-ID field in the proxy header and response body header.

Now we send a request to openresty.org to see how to use this ID.

Screenshot

We see a “Req-ID” in the header.

Screenshot

Request ID Decoder

Let’s go to the Tools page.

Screenshot

Enter the Request ID Decoder page。

Screenshot

Enter the Request ID that we just saw.

Screenshot

Click this button to decode.

Screenshot

We see some detailed information related to this request.

Like domains of the application

Screenshot

the gateway partition

Screenshot

gateway cluster

Screenshot

and gateway server.

Screenshot

Here we have two buttons. You can search the Request ID in the error logs and WAF logs page of the corresponding application.

Screenshot

Let me show you how to do this.

Click the button Search in Error Logs.

Screenshot

We are now landing on the error logs page.

Screenshot

We can’t see any result here as the Request ID we use is from a normal request. It didn’t create any error logs.

Screenshot

If you clear the search criteria.

Screenshot

You can see all error logs with detailed information.

If you copy one request ID.

Screenshot

And paste it into the search box.

Screenshot

You can see that error logs are filtered, and only the error log with the selected Request ID is displayed.

Screenshot

It is the error logs page. Similarly, on the page of suspicious requests intercepted by WAF, all requests also carry the Request ID.

Enter the WAF logs page.

Screenshot

You can see all the requests intercepted by WAF and the corresponding IDs.

And you can also filter the requests using the Request IDs.

Screenshot

You can decode the Request ID directly in the table.

Click on one Request ID.

Screenshot

Screenshot

When you click links on this window, it will bring you to the corresponding page.

For example, click the link to the gateway server. You are now on the page of the gateway server.

Screenshot

The request information window is still open, as you might want to go to other pages.

If you want to close it, just click the close button.

Screenshot

What is OpenResty Edge

OpenResty Edge is our all-in-one gateway software for microservices and distributed traffic architectures. It combines traffic management, private CDN construction, API gateway, security, and more to help you easily build, manage, and protect modern applications. OpenResty Edge delivers industry-leading performance and scalability to meet the demanding needs of high concurrency, high load scenarios. It supports scheduling containerized application traffic such as K8s and manages massive domains, making it easy to meet the needs of large websites and complex applications.

If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!

About The Author

Yichun Zhang (Github handle: agentzh), is the original creator of the OpenResty® open-source project and the CEO of OpenResty Inc..

Yichun is one of the earliest advocates and leaders of “open-source technology”. He worked at many internationally renowned tech companies, such as Cloudflare, Yahoo!. He is a pioneer of “edge computing”, “dynamic tracing” and “machine coding”, with over 22 years of programming and 16 years of open source experience. Yichun is well-known in the open-source space as the project leader of OpenResty®, adopted by more than 40 million global website domains.

OpenResty Inc., the enterprise software start-up founded by Yichun in 2017, has customers from some of the biggest companies in the world. Its flagship product, OpenResty XRay, is a non-invasive profiling and troubleshooting tool that significantly enhances and utilizes dynamic tracing technology. And its OpenResty Edge product is a powerful distributed traffic management and private CDN software product.

As an avid open-source contributor, Yichun has contributed more than a million lines of code to numerous open-source projects, including Linux kernel, Nginx, LuaJIT, GDB, SystemTap, LLVM, Perl, etc. He has also authored more than 60 open-source software libraries.