简体   繁体   中英

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. With this query, i get all the samples in the last 24 hours: 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. The result is the table of distinct values during 24h.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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