简体   繁体   English

Loki LogQL topk聚合 function

[英]Loki LogQL topk aggregate function

I've started shipping traefik access logs (in JSON) to Grafana Loki and wanted to visualize the top 3 ClientHosts.我已经开始将 traefik 访问日志(JSON 格式)发送到 Grafana Loki,并希望可视化前 3 个 ClientHost。 This is the LogQL I have written for this but it returns all ClientHosts for the selected time range instead of only the top 3. What am I missing?这是我为此编写的 LogQL,但它会返回选定时间范围内的所有 ClientHost,而不仅仅是前 3 个。我错过了什么?

topk(3, sum by (ClientHost)(count_over_time({filename="/var/log/traefik/access-json.log"}|json[5m])))

Are you using the "Explore" on Grafana?您在 Grafana 上使用“Explore”吗? Do not forget to select the following option:不要忘记select以下选项:

Query type = Instant

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM