Skip to content

delta()

Calculate the change in a counter from a counter aggregate

Since 1.3.0

Get the change in a counter over a time period. This is the simple delta, computed by subtracting the first value from the last, after accounting for resets.

Get the change in each counter over the entire time interval in table foo.

SELECT
id,
delta(summary)
FROM (
SELECT
id,
counter_agg(ts, val) AS summary
FROM foo
GROUP BY id
) t

The syntax is:

delta(
summary CounterSummary
) RETURNS DOUBLE PRECISION
NameTypeDefaultRequiredDescription
summaryCounterSummary-✔A counter aggregate created using counter_agg
ColumnTypeDescription
deltaDOUBLE PRECISIONThe change in the counter over the bucketed interval