如何在Prometheus + grafana中显示零而不是最后一个值 [英] How to display zero instead of last value in prometheus + grafana

查看:281
本文介绍了如何在Prometheus + grafana中显示零而不是最后一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用prometheus + grafana来收集和显示指标.如果我的设备之一停止报告,grafana将继续绘制最后一个值.例如,如果我的设备之一在2天前报告了温度并且温度为50度,那么grafana将在最近2天显示50度的平线.如果设备未报告任何指标,我希望此时间序列图下降到零.

这仅仅是Prometheus和grafana的行为方式还是我在配置中缺少某些内容?如果设备未报告而不是显示其最后一个值的平线,我希望此时间序列图将零位图表化.

其他信息:

使用prometheus.net将指标推送到Prometheus的推送网关.

我尝试使用grafana中图的Stacking and Null Value部分下的Null value:null作为零选项.

解决方案

这是 TTL或有效期被拒绝了

此问题的通常解决方案是推送测量的Unix时间戳记,并有一条规则警告它是否太旧或使用 UNLESS time()-timestamp_metric 条件.

I'm using prometheus + grafana for collecting and displaying metrics. If one of my devices stops reporting grafana will continue to graph the last value. For example, if one of my devices reported its temperature 2 days ago and the temperature was 50 degrees, grafana will display a flat line for 50 degrees for the last 2 days. I would expect this timeseries graph to dip down to zero if the device wasn't reporting any metrics.

Is this just the way prometheus and grafana behave or am I missing something in the configuration? I would like this timeseries graph to chart zeros if a device is not reporting rather than showing a flat line of its last value.

Additional info:

Using prometheus.net to push metrics to prometheus' push gateway.

I've tried using the Null value: null as zero option under the Stacking and Null Value section of the graph in grafana.

解决方案

This is the expected behavior of push gateway. Once a value is pushed, it will stay forever. This is assumed by the dev team and TTL or expiration of metrics have been refused

The usual solution to this problem is to push a Unix timestamp of the measurement and have a rule alerting if it becomes too old or use a UNLESS time() - timestamp_metric condition.

这篇关于如何在Prometheus + grafana中显示零而不是最后一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆