首页 > 解决方案 > 在grafan中将图表重置为0

问题描述

下面是我在 grafana 中的图表:

在此处输入图像描述

我的问题是,如果我选择的时间范围是 5 分钟,则图表不会仅显示过去 5 分钟内发生的情况。所以在图片中,过去 5 分钟内没有发生任何事情,所以它只是显示了它所拥有的最后一点。如果没有任何变化,我该如何更改它以使其恢复为零?如果相关的话,我正在为此使用 Prometheus 计数器。

标签: grafanaprometheus

解决方案


As explained in the Prometheus documentation, a counter value in itself is not of much use. It depends on when your job was last restarted and everything that happened since.

What's interesting about a counter is how much it changed over some period of time. I.e. either the average rate of change per second (e.g. 3 queries per second) or the increase over some time range (e.g. 10K queries in the last hour).

So instead of graphing something like e.g. http_requests, you should graph rate(http_requests[1m]) (the averate number of requests over the previous 1 minute) or increase(http_requests[1h]) (the total number of requests over the past hour). You can play with the range size until you get something which makes sense for your data. But make sure to use a range at least 2x your scrape interval (and ideally more, as Prometheus is somewhat daft in the way it computes rates/increases).


推荐阅读