Mandroid
Mandroid

Reputation: 7524

Promethus query in grafana using $__interval

In Prometheus querying in grafana, are these queries same resultwise:

sum(increase(mymetrics[$__interval]))
increase(sum(mymetrics)[$__interval])

Upvotes: 0

Views: 247

Answers (1)

trallnag
trallnag

Reputation: 2386

No, they are not the same. The result will not always be the same and the second query will return wrong results if your data contains resets. This is due to the fact that your distinct counter time series may contain resets. If you sum it all up these resets to zero disappear.

The following blog-post explains this well. increase is really just syntactic sugar around rate. So the article can be also applied to increase.

https://www.robustperception.io/rate-then-sum-never-sum-then-rate

Rate then sum, never sum then rate

Upvotes: 3

Related Questions