Kobalelovx
Kobalelovx

Reputation: 23

Topk values in LogQL

I need some help with Loki. I`ve got json logs like following

{"message": {"reason": "reason1"...}}
{"message": {"reason": "reason2"...}}

And I need to print top N reasons. How can I do this?

Upvotes: 2

Views: 6390

Answers (1)

Try the following LogQL

topk(N, sum by (reason) (count_over_time({filename="xxxxx"} | json [1d])))

Upvotes: 4

Related Questions