Skip to main content
Since 1.15.0 Update a heartbeat aggregate to include any live ranges that should have been carried over from the last heartbeat in the predecessor, even if there aren’t heartbeats for that range in the interval covered by this aggregate. Return the updated aggregate, which can then be used with any of the heartbeat aggregate accessors.
interpolate(
    agg HEARTBEATAGG,
    pred HEARTBEATAGG
) RETURNS HEARTBEATAGG

Arguments

NameTypeDefaultRequiredDescription
aggHeartbeatAgg-A heartbeat aggregate containing liveness data for a particular interval
predHeartbeatAgg-The heartbeat aggregate for the preceding interval, if one exists

Returns

ColumnTypeDescription
interpolateHeartbeatAggA copy of agg which has been updated to include any heartbeat intervals extending past the end of pred

Samples

Given a table called liveness containing weekly heartbeat aggregates in column health with timestamp column date, use the following to get the intervals where the system was unhealthy during the week of Jan 9, 2022. This correctly excludes any ranges covered by a heartbeat at the end of the Jan 2 week.
SELECT dead_ranges(
  interpolate(
    health,
    LAG(health) OVER (ORDER BY date)
  )
)
FROM liveness
WHERE date = '01-9-2022 UTC'
Returns:
                    dead_ranges
-----------------------------------------------------
("2022-01-12 15:27:22+00","2022-01-12 15:31:17+00")