You can do:

foo - foo offset 5s

to compare foo with the value it had 5 seconds ago.  Note that if the 
scrapes are not *exactly* 5 seconds apart, there's a small risk that this 
will cover 2 scrapes, or no scrapes.

The reason rate() and increase() don't do this is so that they handle rate 
calculation properly and counter resets properly.

In your case, you have a scrape interval of 5s and are looking at a window 
of 5s.  The window will look like this:

[..10....15....20....23..]
    <--- 15 seconds -->

The time interval between the first and last data points is 15 seconds.  
rate() uses the first and last data points, so it calculates the rate as 
(23-10)/15 = 0.867  (units per second)

increase() scales this to the whole 20 second period, so it calculates 
0.867*20 = 17.33.  It doesn't actually see the values at the start and end 
of the window, but it assumes the rate stays the same, so interpolates the 
expected increase over that period.  As you can see, this can give a 
non-integer value.

If the counter resets it's a bit more complicated:

[..10....15....10....23..]
   <--A--> <-B-> <-C->

We have no idea what happened in time period B; the counter reset.  It 
could have gone 15-->100-->0-->10 or 15-->16-->0-->10.  So that period is 
excluded.

This means you have an increase of 5 for period A, and an increase of 13 
for period C, giving a total known counter increase of 18, over a total 
time period of 10 seconds, giving a rate of 1.8.

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/e61f1380-3df0-4043-aee6-d03f591ee0d0o%40googlegroups.com.

Reply via email to