Not in the presence of counter resets, no.

> My full question, reason for the question, and experiment is here: 
https://github.com/dsabsay/prom_rates_and_counters/blob/main/README.md

"In other words, can one get the equivalent of increase(some_metric[1d]) by 
using the output of a recording rule like rate(some_metric[5m])?

I think that increase(...) doesn't work in the way you think it does.

increase(...) and rate(...) are the same thing, only differing by a factor 
of the time window.  That is: increase(some_metric[1d]) is *exactly* the 
same as rate(some_metric[1d])*86400.

To find the exact difference between a metric now and 1d ago, you can use
some_metric - some_metric offset 1d

However that does not work across counter resets, for obvious reasons.

The underlying requirement you have is, I think, given a collection of 
recorded rate[5m] values, can you turn this into a rate[1d] ?  I think the 
avg_over_time() of those rates is the best you can do.  If these are 5m 
rates, then you'd want 5 minute steps: avg_over_time(    [ xx : 5m] )

But you are testing this over very short time periods (10m) and therefore 
it's not going to be exact. In particular, rate([5m]) takes the rate 
between the first and last data points in a 5 minute window. This means 
that if you are scraping at 1 minute intervals, you're actually calculating 
a rate over a 4 minute period.

On Thursday, 29 June 2023 at 07:22:43 UTC+1 Daniel Sabsay wrote:

> Is it possible to accurately calculate original counts from pre-recorded 
> rates?
> My experiments suggest the answer is no. But I’m curious to get other 
> perspectives to see if I’ve overlooked something or if there is a more 
> effective way to approach this.
>
> My full question, reason for the question, and experiment is here: 
> https://github.com/dsabsay/prom_rates_and_counters/blob/main/README.md
>
> Thanks!
>

-- 
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/19209590-7c4f-452e-ab0c-be3f0e52cad7n%40googlegroups.com.

Reply via email to