Logs & troubleshooting 3
Reading access and error logs with grep, awk and sort to find what broke and when.
- Find which paths return 5xx in an Nginx access log
Count server errors per path with awk, merge query strings, and narrow by status code and time window — one-liners for the default combined format.
Nginx combined log format · GNU awk 5.2 · generated test log (Ubuntu 24.04) - Read a HAProxy log line — status code and termination state
Split an option httplog line into fields, read the first two characters of the termination state, then count them and list slow requests with awk.
Ubuntu 24.04 · HAProxy 2.8.16 · explanations follow the HAProxy 2.8 configuration manual - Tell the cause of an Nginx 502 Bad Gateway from error.log
The access log only says 502. Match four error.log messages to their causes and the command that confirms each, and tell them apart from a 504.
Ubuntu 24.04.5 · Nginx 1.24.0 · Python 3.12 (test backends)