简体   繁体   English

Grafana Loki 特定日志消息的总数

[英]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.我正在使用 Grafana Loki,我需要计算特定时间间隔内特定日志消息的总数。 For example, I need the total number of log message "some-text" in the period from 12:00:00 to 14:00:00.例如,我需要从 12:00:00 到 14:00:00 期间的日志消息“some-text”的总数。 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.我刚刚找到了以下方法来计算最后一分钟的出现次数,例如: count_over_time({container="some-containter"} |= "some-text")[1m] ,但我没有找到任何查询方法一个特定的间隔。

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 .如果您使用Grafana Explore来查询您的日志,您可以进行instant查询并使用时间范围和全局变量

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])因此,您可以选择如下屏幕截图所示的时间范围,您的查询将变为count_over_time({container="some-containter"} |= "some-text"[$__range])

You can check my example in the Grafana Playground.您可以在Grafana Playground 中查看我的示例。 在此处输入图像描述

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

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