In OpenResty Edge, a request ID (the Req-ID header) is a unique identifier the gateway attaches to every request so you can trace one specific request across a complex, distributed system. It is enabled by default and appears in both the proxy request header and the response header. When something goes wrong, you paste that ID into Edge Admin’s built-in Request ID Decoder to reveal which application domain, gateway partition, gateway cluster, and gateway server handled the request — then jump straight to the matching entries in the error logs and WAF logs. This tutorial walks through enabling the request ID, decoding one, and using it to filter error and WAF logs for a single request.

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

Tracking a single request across many services in a large distributed system

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

OpenResty Edge attaches a unique Req-ID to every request for easy tracking

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.

OpenResty Edge Admin web console dashboard

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

Opening the Global Config page in OpenResty Edge Admin

The Request ID setting on the global config page

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

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

Sending a request to openresty.org to inspect its Req-ID

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

The Req-ID field returned in the response header

Request ID Decoder

Let’s go to the Tools page.

Opening the Tools page in OpenResty Edge Admin

Enter the Request ID Decoder page。

The Request ID Decoder page in OpenResty Edge

Enter the Request ID that we just saw.

Pasting the Req-ID into the Request ID Decoder input

Click this button to decode.

Clicking the decode button in the Request ID Decoder

We see some detailed information related to this request.

Like domains of the application

Decoded request ID showing the application domains

the gateway partition

Decoded request ID showing the gateway partition

gateway cluster

Decoded request ID showing the gateway cluster

and gateway server.

Decoded request ID showing the 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.

Buttons to search this request ID in the error logs and WAF logs

Let me show you how to do this.

Click the button Search in Error Logs.

Clicking Search in Error Logs for the decoded request ID

We are now landing on the error logs page.

The OpenResty Edge error logs page filtered by the request ID

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.

No error logs for a normal request’s ID

If you clear the search criteria.

Clearing the search criteria on the error logs page

You can see all error logs with detailed information.

If you copy one request ID.

Copying a request ID from an error log entry

And paste it into the search box.

Pasting the request ID into the error logs search box

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

Error logs filtered down to the single selected request ID

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.

The OpenResty Edge WAF logs page listing intercepted requests

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

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

Filtering WAF logs by a request ID in OpenResty Edge

You can decode the Request ID directly in the table.

Click on one Request ID.

Clicking a request ID in the WAF logs table to decode it

Inline decoded request information popup in the WAF logs table

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.

Following the decoded link through to the gateway server page

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.

Closing the request information popup window

FAQ

What is a request ID in OpenResty Edge?

A request ID is a unique identifier that OpenResty Edge attaches to every request so you can track one specific request as it moves through a complex, distributed system. It appears as a Req-ID field in both the proxy request header and the response header, and the setting is turned on by default on the global config page. Because the ID encodes where the request was handled, you can later decode it to trace the request back to a single application, gateway partition, cluster, and server.

How do I decode a request ID in OpenResty Edge?

Open the Tools page in Edge Admin and go to the Request ID Decoder, paste in the Req-ID value, and click decode. Edge shows the application domains, the gateway partition, the gateway cluster, and the gateway server that handled that request. You can also decode a request ID inline: on the WAF logs page, click a request ID directly in the table to open the same decoded information without leaving the page.

How do I find the error logs or WAF logs for a specific request?

After decoding a request ID, use the Search in Error Logs and Search in WAF Logs buttons to jump straight to the matching entries for that exact request. On the error logs page you can also paste a request ID into the search box to filter the view down to the single log line for that request, and the WAF logs page supports the same request-ID filtering — so you never have to scan through unrelated log entries. If you want to search a request ID across more than logs, see Global Search in OpenResty Edge.

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.