In OpenResty Edge, you check error logs in two places: each application has its own error logs page in the Admin console, and the dashboard shows the global error logs collected across all gateway servers. Both let you filter by Request ID, gateway, server, log level, and time interval, and you can always drill down to the raw error.log file on an individual gateway or Admin server. This tutorial walks through all of them, and how they relate to per-request tracing via the Request ID (Req-ID) and to access logs.

OpenResty Edge error log overview diagram

How to view application error logs in OpenResty Edge

As always, let’s go to the OpenResty Edge’s Admin web console. This is our sample deployment of the console. Every user has their local deployment.

OpenResty Edge Admin console login screen

We can still use our continuing sample application, test-edge.com.

Application list showing the test-edge.com sample application

Let’s enter this application.

Entering the test-edge.com application in the Admin console

Click here to view the error logs of this application.

Menu entry for the application error logs page

We can see that there are already some error logs recorded here. This page displays some important information about the error log.

Application error logs page listing recorded error entries

Such as Request ID, Error log message, Host name, Request body, Client IP addresses, etc.

Error log entry fields: Request ID, message, host name, request body, client IP

Let’s make some changes for test-edge.com and visit the domain to generate a new error log message.

We already have a page rule defined.

Existing page rule for test-edge.com

This page rule sets up a reverse proxy to a pre-defined upstream.

Page rule configured as a reverse proxy to an upstream

Let’s go to the upstream page.

Upstream configuration page in OpenResty Edge

Let’s edit the upstream server.

Editing the upstream server entry

We disable this upstream server. After disabling upstream, we will get a bad gateway error when accessing the application.

Disabling the upstream server to trigger a bad gateway error

Save this change.

Saving the upstream server change

As always, we need to make a new release to push out our edited page rule.

Creating a new release to push the edited page rule

Click on this button.

Release confirmation button in the Admin console

Ship it!

Shipping the release to all gateway servers

Our new release is now synchronized to all our gateway servers.

Release synchronized across all gateway servers

Now the new page rule has been pushed to all the gateway clusters and servers.

Configuration syncing to gateway clusters — start of the sync animation

Configuration syncing to gateway clusters — sync completing

Our configuration changes do NOT require server reload, restart, or binary upgrade. So it’s very efficient and scalable.

Live configuration sync without server reload or restart

Now let’s try to send a request.

On the terminal, we send a request by curl.

curl -sSI http://test-edge.com

Sending a curl request to test-edge.com from the terminal

We can see the bad gateway error, which will be recorded in our application’s error log.

Terminal showing the 502 Bad Gateway response

And we can see that the server-side response has a request ID. We can copy it and use it to find the corresponding log message.

Response headers showing the Req-ID request ID value

Let’s go back to the application’s error logs page. Check the error log message we generated.

Returning to the application error logs page to locate the new entry

As we expected, an error log was generated. Our newly generated error log will appear at the top of the list.

Newly generated bad gateway error log at the top of the list

Filtering error logs by Request ID, gateway, server, and log level

The error logs for this domain are few. Let’s look at the error logs for the other domains we already have online.

Go to the Application list page.

Application list page with multiple online domains

Let’s see the error logs of the OpenResty website.

Selecting the OpenResty website application

Go to the page.

Opening the OpenResty website application

Go to the error logs page. There are more error logs recorded here.

Error logs page for openresty.com with many recorded entries

This filtering query condition is conducive to locating the problem.

Error log filter query conditions for locating problems

We can filter the messages by request ID.

Filtering error log messages by Request ID

Gateway.

Filtering error log messages by gateway

Server.

Filtering error log messages by server

Error log level.

Filtering error log messages by error log level

And time interval.

Filtering error log messages by time interval

Let’s try filtering messages by a gateway.

Selecting a gateway to filter error log messages

We select the aws-us-west gateway.

Filtering by the aws-us-west gateway

We can see that there is no error log under the aws-us-west gateway.

The three types of global error logs in OpenResty Edge

After understanding the application’s error logs, let’s see the global error logs. The global error logs are displayed on the dashboard page.

Dashboard page showing the global error logs section

Global error logs entry point on the dashboard

Let’s go to the dashboard page to see the global error logs.

Navigating to the dashboard global error logs

There are three types of global error logs.

The three types of global error logs: Global, Admin Site, Log Server

Global Error Logs.

Global Error Logs tab

Admin Site Error Logs.

Admin Site Error Logs tab

Log Server Error Logs.

Log Server Error Logs tab

Let’s first look at global error logs.

Viewing the Global Error Logs list

Global error logs are collected from gateway servers and do not belong to any applications.

Global error logs collected from gateway servers, not tied to any application

We can filter the error logs.

Filtering the global error logs

Let’s continue to see the Admin Site Error logs.

Opening the Admin Site Error Logs

These error logs are collected from the Admin console.

Admin Site Error Logs collected from the Admin console

We also support conditional filtering of logs.

Conditional filtering of the Admin Site Error Logs

Let’s select the Log Level “Error”.

Selecting the Error log level filter

We have highlighted logs with “error” levels and repeat times greater than 1.

Highlighted error-level logs with a repeat count greater than one

And last, let’s see the Log Server Error logs.

Opening the Log Server Error Logs

Error logs collected are from the OpenResty Edge Log Server.

Log Server Error Logs collected from the OpenResty Edge Log Server

And we can also filter the logs.

Filtering the Log Server Error Logs

As we can see, there are log levels for both global and application logs, but not every log level we have reported.

Comparing available log levels for global and application logs

The log level to be reported can be set on the global config page.

Global config page where the reported log level is set

Here we set it to “warn”, meaning only warnings and log messages of higher levels are reported.

Setting the reported log level to warn

The error log level here contains “warn”, “error”, “crit”, “alert”, etc.

Available log levels: warn, error, crit, alert

And on your local deployment, you can set the log level you want.

How to check the error.log file on gateway and Admin servers

Let’s log into the OpenResty Edge gateway server and take a look at our error.log file.

Logging into a gateway server over SSH

Check the last error log message.

Checking the last error log message on the gateway server

The error log messages of our gateway servers are written here.

Location of the gateway server error.log file

Run the command.

Running a command to read the gateway error.log

We can see the gateway server error log message.

Gateway server error log message displayed in the terminal

Quit the server.

Exiting the gateway server SSH session

Then, we log into the OpenResty Edge Admin server and check the error.log file.

Logging into the OpenResty Edge Admin server

Let’s look at the last error log messages again.

Checking the last error log messages on the Admin server

The error log messages of the OpenResty Edge Admin are written here.

Location of the OpenResty Edge Admin error.log file

Run the command.

Running a command to read the Admin error.log

We can see the OpenResty Edge Admin error log message.

OpenResty Edge Admin error log message displayed in the terminal

Frequently asked questions

Where can I view error logs in OpenResty Edge?

There are two places. Each application has its own error logs page inside the Admin console, showing errors for that application’s domains. Separately, the dashboard shows the global error logs collected across all gateway servers. For the raw files, you can also SSH into a gateway or Admin server and read its error.log directly.

How do I find the error log for a specific request?

Every response from OpenResty Edge carries a Request ID in its headers (shown as Req-ID). Copy that value and paste it into the Request ID filter on the application’s error logs page to jump straight to the matching entry. See What is a Request ID for how request tracing works end to end.

What are the three types of global error logs?

On the dashboard, global error logs are split into Global Error Logs (collected from the gateway servers, not tied to any application), Admin Site Error Logs (collected from the Admin console), and Log Server Error Logs (collected from the OpenResty Edge Log Server). Each can be filtered by log level and other conditions.

How do I set which error log levels are reported?

The reported log level is configured on the global config page. Setting it to warn, for example, means only messages at warn level and above are reported. The available levels include warn, error, crit, and alert. On your own local deployment you can pick whichever level you need.

How do I filter error logs to locate a problem?

The error logs page lets you narrow results by Request ID, gateway, server, error log level, and time interval. For example, you can select a single gateway (such as aws-us-west) to confirm whether errors are isolated to one location, or select the Error level to surface only the most severe messages.

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.