I have a Prometheus metric called device_number
. What I want is to show the difference in value between now and one day/week/month etc ago. Which means subtracting two values with two different timestamps.
Checking around I don't find any useful documentation on how to do it.
Something I would do, but doesn't work is:
sum(device_number) - sum(device_number[$__range])
delta() delta(v range-vector) calculates the difference between the first and last value of each time series element in a range vector v , returning an instant vector with the given deltas and equivalent labels.
Prometheus Data Types Range Vector : A range vector is a set of time series containing a range of data points over time for each time series. Unlike an instant vector which returns one sample per time series, a range vector can return many samples for each time series.
Prometheus rate function is the process of calculating the average per second rate of value increases. You would use this when you want to view how your server CPU usage has increased over a time range or how many requests come in over a time range and how that number increases.
irate() ("instant rate"): This calculates the rate of increase per second just like rate() , but only considers the last two samples under the provided time window for the calculation and ignores all earlier ones.
I found offset
is the correct keyword.
Query like this:
sum(vss_device_number) - sum(vss_device_number offset 1d)
Will return difference between now and yesterday.
Docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With