LogQL: rate of 4xx responses per path from unstructured NGINX access logs?
AdvancedProductionRapid-Fire PromQL & LogQL
Answer
sum by (path) (rate(
{app="ingress-nginx"}
| pattern "<ip> - <_> [<_>] \"<method> <path> <_>\" <status> <size> <_>"
| status >= 400 | status < 500 [5m]))
The pattern parser is faster and easier to read than regexp for fixed-format lines. Watch cardinality: if path contains IDs, normalise it with label_format or group by a coarser label.
More on Rapid-Fire PromQL & LogQL
Requests per second per service over the last 5 minutes?BeginnerPercentage of 5xx responses per service?Beginnerp99 latency per route from a histogram?IntermediateTop 5 pods by CPU usage in a namespace?BeginnerMemory working set as a percentage of the container limit?IntermediateWhich scrape targets are down right now?Beginner