10

I'm trying to figure out the difference between the in-application modifier as_rate() and the rollup function per_second().

I want a table with two columns: the left column shows the total number of events submitted to a Distribution (in query-speak: count:METRIC{*} by {tag}), and the right column shows the average rate of events per second. The table visualization applies a sum rollup on left column, and an average rollup on the right column, so that the left column should equal the right column multiplied by the total number of seconds in the selected time period.

From reading the docs I expected either of these queries to work for the right column:

count:DISTRIBUTION_METRIC{*} by {tag}.as_rate()

per_second(count:DISTRIBUTION_METRIC{*} by {tag})

But, it turns out that these two queries are not the same. as_rate() is the only one that finds the expected average rate where left = right * num_seconds. In fact, the per_second() rollup does this extra weird thing where metrics with lower total events have higher average rates.

Is someone able to clarify why these two functions are not synonymous and what per_second() does differently?

0 Answers0