Calculate the rate of change in a counter over a time period. Data points at the exact
boundaries of the time period aren't needed. The function linerally interpolates the
counter values at the boundaries from adjacent
CounterSummaries if they are unknown.
This is the same value as an
interpolated_delta divided by the duration in seconds.
interpolated_rate( summary CounterSummary, start TIMESTAMPTZ, interval INTERVAL, prev CounterSummary, next CounterSummary ) RETURNS DOUBLE PRECISION
For more information about counter aggregation functions, see the hyperfunctions documentation.
|The input |
|The start of the interval which the rate should be computed over (if there is a preceeding point)|
|The length of the interval which the rate should cover|
|The CounterSummary from the following interval, used to interpolate the value at |
|The per-second rate of change of the counter between the specified bounds. If the raw data contains no points calculated at those bounds, the bounding values are linearly interpolated from neighboring |
SELECT id, bucket, interpolated_rate( summary, bucket, '15 min', LAG(summary) OVER (ORDER by bucket PARTITION BY id), LEAD(summary) OVER (ORDER by bucket PARTITION BY id) ) FROM ( SELECT id, time_bucket('15 min'::interval, ts) AS bucket, counter_agg(ts, val) AS summary FROM foo GROUP BY id, time_bucket('15 min'::interval, ts) ) t
Found an issue on this page?Report an issue!