Reputation: 23
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
Reputation: 22311
Try the following LogQL
topk(N, sum by (reason) (count_over_time({filename="xxxxx"} | json [1d])))
Upvotes: 4