Skip to content

Latest commit

 

History

History
70 lines (69 loc) · 2.34 KB

counter_agg.md

File metadata and controls

70 lines (69 loc) · 2.34 KB
api_name excerpt topics api hyperfunction api_details
counter_agg()
Aggregate counter data into an intermediate form for further analysis
hyperfunctions
license type toolkit experimental version
community
function
true
false
experimental stable
0.2.0
1.3.0
family type aggregates
counters and gauges
aggregate
counter_agg()
summary signatures parameters examples
This is the first step for performing any aggregate calculations on counter data. Use `counter_agg` to create an intermediate aggregate from your data. This intermediate form can then be used by one or more accessors in this group to compute final results. Optionally, you can combine multiple intermediate aggregate objects using [`rollup()`](#rollup) before an accessor is applied.
language code
sql
counter_agg( ts TIMESTAMPTZ, value DOUBLE PRECISION [, bounds TSTZRANGE] ) RETURNS CounterSummary
required optional returns
name type description
ts
TIMESTAMPTZ
The time at each point
name type description
value
DOUBLE PRECISION
The value of the counter at each point
name type description
bounds
TSTZRANGE
The smallest and largest possible times that can be input to this aggregate. Bounds are required for extrapolation, but not for other accessor functions. If you don't specify bounds at aggregate creation time, you can add them later using the [`with_bounds`](#with_bounds) function.
column type description
counter_agg
CounterSummary
The counter aggregate, containing data about the variables in an intermediate form. Pass the aggregate to accessor functions in the counter aggregates API to perform final calculations. Or, pass the aggregate to rollup functions to combine multiple counter aggregates into larger aggregates.
description command
Create a counter aggregate to summarize daily counter data.
code
SELECT time_bucket('1 day'::interval, ts) as dt, counter_agg(ts, val) AS cs FROM foo WHERE id = 'bar' GROUP BY time_bucket('1 day'::interval, ts)