ill-formed log in Loki

Viewed 323

I'm using zerolog in golang, which outputs json formatted log, the app is running on k8s, and has cri-o format as following. actual log screenshot on Grafana loki

My question is, since there's some non-json text prepended to my json log, I can't seem to effectively query the log, one example is, when I tried to pipe the log into logfmt, exceptions were thrown.

What I want is to be able to query into the sub field of the json. My intuition is to maybe for each log, only select the parts from { (start of the json), then maybe I can do more interesting manipulation. I'm a bit stuck and not sure what's the best way to proceed.

Any help and comments is appreciated.

1 Answers
Related