简体   繁体   中英

Grafana Loki total number of a specific log message

I am using Grafana Loki and I need to calculate the total number of a certain log message for a specific time interval. For example, I need the total number of log message "some-text" in the period from 12:00:00 to 14:00:00. I just found the following way to count the occurrences of the last minute, something this: count_over_time({container="some-containter"} |= "some-text")[1m] , but i did not found any way to query a specific interval.

I would be very happy if this is possible and someone could help.

If you're using Grafana Explore to query your logs you can do an instant query and use the time range and global variables .

So you can select the time range as seen in the screenshot below and your query would become count_over_time({container="some-containter"} |= "some-text"[$__range])

You can check my example in the Grafana Playground. 在此处输入图像描述

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