Prometheus 获取最后记录的指标值

Prometheus get last value recorded for metric

我不确定这是否可能,如果是这样我会很高兴,但是:

假设我有一个指标,最后一次出现是在 14 天前。我如何查询普罗米修斯特定范围内(即 30 天)的最后一个值及其日期?

您似乎希望获得 Prometheus 在一段时间内存储的原始指标。 extracting raw samples from prometheus.

自 2.2.0(2021 年 3 月)prometheus 发布以来,'last_over_time' 允许您准确检索您需要的内容:

last_over_time(my_metric[14d])

文档:https://prometheus.io/docs/prometheus/latest/querying/functions/#aggregation_over_time