Skip to main content
Since 1.3.0 Calculate the time when the counter value is predicted to have been zero. This is the x-intercept of the linear fit between counter value and time.

Arguments

NameTypeDefaultRequiredDescription
summaryCounterSummary-A counter aggregate created using counter_agg

Returns

TIMESTAMPTZ: The time when the counter value is predicted to have been zero

Samples

Estimate the time when the counter started
SELECT
    id,
    bucket,
    counter_zero_time(summary)
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