简体   繁体   中英

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. 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?

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

Are you using the "Explore" on Grafana? Do not forget to select the following option:

Query type = Instant

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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