Home > front end >  Get a number from JSON by Promtail
Get a number from JSON by Promtail

Time:12-23

I use Promtail Loki to collect my logs.
Input logs are JSON strings that look like this:

{ "severity":"error",  "msg":"very bad error", "duration":20 }

How can I parse this string by Promtail to get duration as numeric in Loki?
My goal is to be able to make queries like this:

{job="job_name"}|duration>10s

CodePudding user response:

The following PromQL should work:

{job="job_name"} | json | duration>10

You can't use values like "10s", but you can use "10K" or "10M" ones.

  • Related