Using request IDs to troubleshoot problematic requests in OpenResty Edge gateways
As your business grows, your system may become increasingly complex. It becomes crucial and challenging to be able to track requests correctly.
OpenResty Edge makes things a little easier by enabling requests to be identified with a unique ID. It is our topic today: Request ID.
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.
Now go to the global config page. Here you can configure whether you add a Request ID to the header of all requests.
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.
We see a “Req-ID” in the header.
Request ID Decoder
Let’s go to the Tools page.
Enter the Request ID Decoder page。
Enter the Request ID that we just saw.
Click this button to decode.
We see some detailed information related to this request.
Like domains of the application
the gateway partition
gateway cluster
and gateway server.
Here we have two buttons. You can search the Request ID in the error logs and WAF logs page of the corresponding application.
Let me show you how to do this.
Click the button Search in Error Logs.
We are now landing on the error logs page.
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.
If you clear the search criteria.
You can see all error logs with detailed information.
If you copy one request ID.
And paste it into the search box.
You can see that error logs are filtered, and only the error log with the selected Request ID is displayed.
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.
You can see all the requests intercepted by WAF and the corresponding IDs.
And you can also filter the requests using the Request IDs.
You can decode the Request ID directly in the table.
Click on one Request ID.
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.
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.
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.