grafana loki特定日志消息的总数

发布于 2025-02-07 00:59:52 字数 247 浏览 2 评论 0原文

我正在使用Grafana Loki,需要计算特定时间间隔的特定日志消息的总数。例如,我需要在12:00:00至14:00:00的期间内的日志消息“某些文本”的总数。我刚刚找到了以下方法来计算最后一分钟的出现,这是:count_over_time({container =“ some-containter”} | =“ some-text”)[1M],但是我没有找到任何查询特定间隔的方法。

如果可能的话,我会很高兴,有人可以提供帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瑶笙 2025-02-14 00:59:52

如果您正在使用 grafana explore 查询日志,您可以做> > instant查询并使用时间范围,全局变量

因此,您可以选择下面屏幕截图中看到的时间范围,您的查询将变成
count_over_time({container =“ some-container”} | =“ some-text” [$ __范围])

您可以在“ noreferrer”> grafana游乐场。

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-container"} |= "some-text"[$__range])

You can check my example in the Grafana Playground.
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文