最近的值或上次看到的值 [英] Most recent value or last seen value
问题描述
Prometheus 是围绕返回指标的时间序列表示而构建的.然而,在许多情况下,我只关心指标的现在状态,而且我很难找到一种可靠的方法来获得一个指标的最新"值.指标.
Prometheus is built around returning a time series representation of metrics. In many cases, however, I only care about what the state of a metric is right now, and I'm having a hard time figuring out a reliable way to get the "most recent" value of a metric.
因为现在它每 30 秒获取一次指标,我尝试了这样的操作:
Since right now it's getting metrics every 30 seconds, I tried something like this:
my_metric[30s]
但这感觉很脆弱.如果指标在数据点之间的日期超过或少于 30 秒,那么我要么得到一个以上的结果,要么返回零个结果.
But this feels fragile. If metrics are dated any more or less than 30 seconds between data points, then I either get back more than one or zero results.
如何获取指标的最新值?
How can I get the most recent value of a metric?
推荐答案
您只需要 my_metric
,它会默认返回不超过 5 分钟的最新值.
All you need is my_metric
, which will by default return the most recent value no more than 5 minutes old.
这篇关于最近的值或上次看到的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!