counter_agg instead to appropriately account for resets.
Two-step aggregation
This group of functions uses the two-step aggregation pattern. Rather than calculating the final result in one step, you first create an intermediate aggregate by using the aggregate function. Then, use any of the accessors on the intermediate aggregate to calculate a final result. You can also roll up multiple intermediate aggregates with the rollup functions. The two-step aggregation pattern has several advantages:- More efficient because multiple accessors can reuse the same aggregate
- Easier to reason about performance, because aggregation is separate from final computation
- Easier to understand when calculations can be rolled up into larger intervals, especially in window functions and continuous aggregates
- Perform retrospective analysis even when underlying data is dropped, because the intermediate aggregate stores extra information not available in the final result
Samples
Analyze gauge metrics
Create hourly gauge aggregates and calculate changes:Available functions
Aggregate
gauge_agg(): aggregate gauge data into an intermediate form for further analysis
Accessors
corr(): calculate the correlation coefficient from a gauge aggregatedelta(): calculate the change in a gauge’s valueextrapolated_delta(): estimate the total change in a gauge over a time periodextrapolated_rate(): estimate the average rate of change over a time periodgauge_zero_time(): calculate the time when a gauge value was zeroidelta_left(): calculate the instantaneous change at the left boundaryidelta_right(): calculate the instantaneous change at the right boundaryintercept(): calculate the y-intercept from a gauge aggregateinterpolated_delta(): calculate the change over a specific time range with interpolationinterpolated_rate(): calculate the rate of change over a specific time range with interpolationirate_left(): calculate the instantaneous rate at the left boundaryirate_right(): calculate the instantaneous rate at the right boundarynum_changes(): get the number of times the gauge changed valuenum_elements(): get the number of points in a gauge aggregaterate(): calculate the average rate of changeslope(): calculate the slope from a gauge aggregatetime_delta(): calculate the elapsed time in a gauge aggregate
Rollup
rollup(): combine multiple gauge aggregates
Mutator
with_bounds(): add time bounds to a gauge aggregate for extrapolation