extrapolated_delta()

The change in the counter during the time period specified by the bounds in the CounterSummary. To calculate the extrapolated delta, any counter resets are accounted for and the observed values are extrapolated to the bounds using the method specified, then the values are subtracted to compute the delta.

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

  1. extrapolated_delta(
  2. summary CounterSummary,
  3. method TEXT
  4. ) RETURNS DOUBLE PRECISION

For more information about counter aggregation functions, see the hyperfunctions documentation.

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_deltaDOUBLE PRECISIONThe delta computed from the CounterSummary

Sample usage

  1. SELECT
  2. id,
  3. bucket,
  4. extrapolated_delta(
  5. with_bounds(
  6. summary,
  7. time_bucket_range('15 min'::interval, bucket)
  8. )
  9. )
  10. FROM (
  11. SELECT
  12. id,
  13. time_bucket('15 min'::interval, ts) AS bucket,
  14. counter_agg(ts, val) AS summary
  15. FROM foo
  16. GROUP BY id, time_bucket('15 min'::interval, ts)
  17. ) t