Configuring error log files in OpenResty Edge
Today I’d show you how to check application error logs and global error logs in OpenResty Edge.
Error logs of the sample application
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.
We can still use our continuing sample application, test-edge.com.
Let’s enter this application.
Click here to view the error logs of this application.
We can see that there are already some error logs recorded here. This page displays some important information about the error log.
Such as Request ID, Error log message, Host name, Request body, Client IP addresses, etc.
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.
This page rule sets up a reverse proxy to a pre-defined upstream.
Let’s go to the upstream page.
Let’s edit the upstream server.
We disable this upstream server. After disabling upstream, we will get a bad gateway error when accessing the application.
Save this change.
As always, we need to make a new release to push out our edited page rule.
Click on this button.
Ship it!
Our new release is now synchronized to all our gateway servers.
Now the new page rule has been pushed to all the gateway clusters and servers.
Our configuration changes do NOT require server reload, restart, or binary upgrade. So it’s very efficient and scalable.
Now let’s try to send a request.
On the terminal, we send a request by curl.
curl -sSI http://test-edge.com
We can see the bad gateway error, which will be recorded in our application’s error log.
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.
Let’s go back to the application’s error logs page. Check the error log message we generated.As we expected, an error log was generated. Our newly generated error log will appear at the top of the list.
Error logs of openresty.com
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.
Let’s see the error logs of the OpenResty website.
Go to the page.
Go to the error logs page. There are more error logs recorded here.
This filtering query condition is conducive to locating the problem.
We can filter the messages by request ID.
Gateway.
Server.
Error log level.
And time interval.
Let’s try filtering messages by a gateway.
We select the aws-us-west gateway.
We can see that there is no error log under the aws-us-west gateway.
Global error logs
After understanding the application’s error logs, let’s see the global error logs. The global error logs are displayed on the dashboard page.
Let’s go to the dashboard page to see the global error logs.
There are three types of global error logs.
Global Error Logs.
Admin Site Error Logs.
Log Server Error Logs.
Let’s first look at global error logs.
Global error logs are collected from gateway servers and do not belong to any applications.
We can filter the error logs.
Let’s continue to see the Admin Site Error logs.
These error logs are collected from the Admin console.
We also support conditional filtering of logs.
Let’s select the Log Level “Error”.
We have highlighted logs with “error” levels and repeat times greater than 1.
And last, let’s see the Log Server Error logs.
Error logs collected are from the OpenResty Edge Log Server.
And we can also filter the logs.
As we can see, there are log levels for both global and application logs, but not every log level we have reported.
The log level to be reported can be set on the global config page.
Here we set it to “warn”, meaning only warnings and log messages of higher levels are reported.
The error log level here contains “warn”, “error”, “crit”, “alert”, etc.
And on your local deployment, you can set the log level you want.
Check error logs on servers
Let’s log into the OpenResty Edge gateway server and take a look at our error.log file.
Check the last error log message.
The error log messages of our gateway servers are written here.
Run the command.
We can see the gateway server error log message.
Quit the server.
Then, we log into the OpenResty Edge Admin server and check the error.log file.
Let’s look at the last error log messages again.
The error log messages of the OpenResty Edge Admin are written here.
Run the command.
We can see the OpenResty Edge Admin error log message.
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.