State aggregates

This section includes functions used to measure the time spent in a relatively small number of states.

For these hyperfunctions, you need to install the TimescaleDB Toolkit PostgreSQL extension.

Notes on state_agg and timeline_agg

timeline_agg supports all hyperfunctions that operate on StateAggs, in addition to some additional functions that need a full state timeline.

All state_agg and timeline_agg hyperfunctions support both string (TEXT) and integer (BIGINT) states. You can’t mix different types of states within a single aggregate. Integer states are useful when the state value is a foreign key representing a row in another table that stores all possible states.

Hyperfunctions

State aggregates functions

Hyperfunction typeHyperfunction nameToolkitExperimental
heartbeat_agg() functions
Aggregateheartbeat_agg()
Accessordead_ranges()
downtime()
interpolate()
interpolated_downtime()
interpolated_uptime()
live_at()
live_ranges()
uptime()
Rolluprollup()
state_agg() | timeline_agg() functions
Aggregatestate_agg(), timeline_agg()
Accessorduration_in()
interpolated_duration_in()
interpolated_state_periods()
interpolated_state_timeline()
into_values()
rollup()
state_periods()
state_timeline()