Dexter
Dexter

Reputation: 377

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?

Upvotes: 0

Views: 3039

Answers (1)

Nycodym Achuprynkin
Nycodym Achuprynkin

Reputation: 41

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.

Upvotes: 2

Related Questions