delta will fail when your counter will be reset (when it will start counting from 0 again), while increase/rate will detect that and adjust result accordingly.
So with:
t0: 5
t1: 11
t2: 28
t3: 4
t4: 40
with delta you'll probably get 40 - 5 = 35, while increase will probably calculate something similar to (28-5)+40 = 63
Just got this in about a week ago. Stonewashed Titanium w/Copper Pill and copper button.
Coming from knives and machined pens so new to this but jumping into the deep end fast. Got a Barrel on the way.
Have a great rest of your week folks 🫡🤘
If you know the interval between samples (e.g. one minute in the example above), then the following subquery can be used:
delta(http_requests[1m])[5m:1m]
This instant query should return the last 5 deltas on 1-minute interval. Unfortunately, it is likely Prometheus will return empty results, since it needs at least two samples on the lookbehind window in square brackets for delta calculations, e.g. it doesn't take into account the difference between the last point before the lookbehind window and the first point in the lookbehind window. So the query must be rewritten to:
delta(http_requests[2m])[5m:1m]
Unfortumatele this query may give unexpected results because of the same issue - Prometheus skips the delta between the last sample before the lookbehind window and the first sample in the lookbehind window [2m].
P.S. An alternative solution is to try the first query in VictoriaMetrics. It takes into account the delta mentioned above, so it must return the expected results. See more details at MetricsQL docs. Take a look also at rollup_delta function - it calculates deltas between consecutive samples on the given lookbehind window and then returns max, min and avg values from the calculated deltas.
Use "delta(http_requests[1m])" and you'll get the delta between each element and its predecessor, as desired.
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.
PromQL also provides delta() function, which can be used for returning the delta between the current time and the time specified in square brackets passed to this function. For example, the following query should return the delta for vss_device_number over the last day (see [1d]):
delta(vss_device_number[1d])
The query returns deltas per each matching time series. If you need summary delta across all the matching time series, then wrap the query into sum():
sum(delta(vss_device_number[1d]))