Rate of Sums vs Sum of Rates

1,956 views
Skip to first unread message

ili...@luminatewireless.com

unread,
Mar 31, 2017, 6:45:24 PM3/31/17
to Prometheus Users
Hi there,

I was reading about the functions offered by Prometheus and came across the following:

"Note that when combining irate() with an aggregation operator (e.g. sum()) or a function aggregating over time (any function ending in _over_time), always take a irate() first, then aggregate. Otherwise irate() cannot detect counter resets when your target restarts."

In a system that has hierarchical federation, how would aggregation work? For example, let's say I have server A and server B, and server C collects data from A and B. If I want to evaluate a rule that requires aggregating data from servers A and B, would Prometheus compute the sum of rates instead of the rate of sums, so as to defend against counter resets and missing data?

Thanks,
Ilina

Julius Volz

unread,
Mar 31, 2017, 6:50:12 PM3/31/17
to Ilina Mitra, Prometheus Users
Federation creates no problem here. There's two possibilities:

1) You federate raw counter data from A and B into C. In this case, you'd have to apply the rate yourself in C before summing:

  sum by(foo) (irate(my_federated_counter_total[1m]))

2) A and B already compute rates via recording rules and C then federates over those rates. Then you'd just need to sum.

In both cases, you end up doing the rate first and the sum second. The only way you can get the two the wrong way around is if you record the sum of raw counters via recording rules first, and then take a rate over the result of that recording rule. Otherwise, Prometheus prevents you to take the range ([1m]) of something that is not a pure time series selector, but some arbitrary expression.
 
Thanks,
Ilina

--
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 prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/0ee2621a-6a28-4a4b-ae69-148edc10d0a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ilina Mitra

unread,
Mar 31, 2017, 6:54:59 PM3/31/17
to Julius Volz, Prometheus Users
Ok thanks for the clarification. So in general, the philosophy is to sum the rates instead of calculating the rate of the sums, right?

Julius Volz

unread,
Mar 31, 2017, 6:55:57 PM3/31/17
to Ilina Mitra, Prometheus Users
Yep. And Prometheus makes it kinda difficult to do the wrong thing in the normal case.

Ilina Mitra

unread,
Mar 31, 2017, 6:56:43 PM3/31/17
to Julius Volz, Prometheus Users
Cool, thanks for the quick response! :)
Reply all
Reply to author
Forward
0 new messages