Skip to main content
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.
live_at(
    agg HEARTBEATAGG,
    test TIMESTAMPTZ
) RETURNS BOOL

Arguments

NameTypeDefaultRequiredDescription
aggHeartbeatAgg-A heartbeat aggregate to get the liveness data from
testTimestampTz-The time to test the liveness of

Returns

ColumnTypeDescription
live_atboolTrue if the heartbeat aggregate had a heartbeat close before the test time

Samples

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