Skip to content

Instantly share code, notes, and snippets.

@linktohack
Created December 16, 2022 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linktohack/a0207744dee84fb870eef9ab1df378f9 to your computer and use it in GitHub Desktop.
Save linktohack/a0207744dee84fb870eef9ab1df378f9 to your computer and use it in GitHub Desktop.
Pattern to match loki's log (Nginx and LB app)
api.driver.cloud.private
api.driver.cloud.transalliance.eu
|~ "(?i)error"
|= `ms {`
| pattern `<ts> stdout F <method> <url> <code> <ms>ms {`
| pattern `<_> "request_method": "<request_method>", "request_uri": "<request_uri>", "request_id": "<request_id>", "status": <status>, "upstream_status": <upstream_status>, "request_time": <request_time>, "upstream_response_time": <upstream_response_time>, "upstream_connect_time": <upstream_connect_time>, "upstream_header_time": <upstream_header_time>`
{job=~"kube-system/.*-crc81um9ef04uh4042gpug-.*"}
|= "api.driver.cloud.private"
!= "/upload"
!= "/download"
!= "getAverageTrip"
| unwrap request_time
| __error__ = ""
count_over_time(
[1m])
rate(
[1m])
sum(count_over_time(
[1m]))
sum(rate(
[1h]))
quantile_over_time(0.99,
[1m]) by (request_uri)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment