Loki parse JSON and filter by field

Viewed 2362

I'm logging a JSON which is being shown as a detected field log in Grafana:

Screenshot of detected fields

Now I want to filter the logs by level name, but I can't figure out how...

I thought something like this would work, but doesn't, no results are returned:

{app="hello"} | json | line_format "{{.log}}" | levelname="ERROR"

What am I missing?

1 Answers

Everything is Ok with the LogQL, but something is wrong with your JSON log line. You should have several detected fields (like "asctime", "created", "filename", etc) instead of just the "log" one, and you also should have the "Log labels" section.

Maybe you should start verifying why the quotes are escaped with ""?

See a working example following:

enter image description here

Related