Skip to content

live_at()

Test if the aggregate has a heartbeat covering a given time

Since 1.15.0

Determine whether the aggregate has a heartbeat indicating the system was live at a given time.

Note that this returns false for any time not covered by the aggregate.

Given a table called liveness containing weekly heartbeat aggregates in column health with timestamp column date, use the following to see if the system was live at a particular time.

SELECT live_at(health, '2022-01-12 15:30:00+00')
FROM liveness
WHERE date = '01-9-2022 UTC'

Returns:

live_at
---------
f

The syntax is:

live_at(
agg HEARTBEATAGG,
test TIMESTAMPTZ
) RETURNS BOOL
NameTypeDefaultRequiredDescription
aggHeartbeatAgg-A heartbeat aggregate to get the liveness data from
testTimestampTz-The time to test the liveness of
ColumnTypeDescription
live_atboolTrue if the heartbeat aggregate had a heartbeat close before the test time.