extrapolated_rate()

The rate of change in the counter computed over the time period specified by the bounds in the CounterSummary, extrapolating to the edges. It is an extrapolated_delta divided by the duration in seconds.

The bounds must be specified for the extrapolated_rate function to work. The bounds can be provided in the counter_agg call, or by using the with_bounds utility function.

extrapolated_rate(
    summary CounterSummary,
    method TEXT¹
) RETURNS DOUBLE PRECISION

For more information about counter aggregation functions, see the [hyperfunctions documentation][hyperfunctions-counter-agg].

Required arguments

NameTypeDescription
summaryCounterSummaryThe input CounterSummary from a counter_agg call
methodTEXTThe extrapolation method to use. Not case-sensitive.

Currently, the only allowed value of method is prometheus, as we have only implemented extrapolation following the Prometheus extrapolation protocol.

Returns

NameTypeDescription
extrapolated_rateDOUBLE PRECISIONThe per-second rate of change of the counter computed from the CounterSummary extrapolated to the bounds specified there.

Sample usage

SELECT
    id,
    bucket,
    extrapolated_rate(
        with_bounds(
            summary,
            time_bucket_range('15 min'::interval, bucket)
        )
    )
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
``
`

[hyperfunctions-counter-agg]: timescaledb/:currentVersion:/how-to-guides/hyperfunctions/counter-aggregation/


export const _frontmatter = {}

Found an issue on this page?

Report an issue!

Related Content