简体   繁体   English

Prometheus Query 在最后一天获得不同的值

[英]Prometheus Query to get distinct value in the last one day

I have a metric that is ingested frequently but the value doesnt change too often.我有一个经常被摄取的指标,但值不会经常变化。 Lets say it might have changed 5 times in the last 24 hours.假设它在过去 24 小时内可能已经更改了 5 次。 With this query, i get all the samples in the last 24 hours: sample.metric.capacity[24h].通过这个查询,我得到了过去 24 小时内的所有样本:sample.metric.capacity[24h]。 But I only want the five distinct values in that time period.但我只想要那个时间段内的五个不同的值。 How can i change the query to get that list of values?如何更改查询以获取该值列表?

You could try to use something like:你可以尝试使用类似的东西:

((changes(your_metric[1m]) * your_metric) > 0)[24h:]

Changes will show only value changes.更改将仅显示值更改。 The value of the changes metric is 1, then it is multiplied by your metric value.更改指标的值为 1,然后乘以您的指标值。 The result is the table of distinct values during 24h.结果是 24 小时内不同值的表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM