Skip to content

downtime()

Get the total time dead during a heartbeat aggregate

Since 1.15.0

Sum all the ranges where the system did not have a recent enough heartbeat from a heartbeat aggregate.

There may appear to be some downtime between the start of the aggregate and the first heartbeat. If there is a heartbeat aggregate covering the previous period, you can use its last heartbeat to correct for this using interpolated_downtime().

Given a table called liveness containing weekly heartbeat aggregates in column health with timestamp column date, use the following to get the total downtime of the system during the week of Jan 9, 2022.

SELECT downtime(health)
FROM liveness
WHERE date = '01-9-2022 UTC'

Returns:

downtime
--------
00:04:25

The syntax is:

downtime(
agg HEARTBEATAGG
) RETURNS INTERVAL
NameTypeDefaultRequiredDescription
aggHeartbeatAgg-A heartbeat aggregate to get the liveness data from
ColumnTypeDescription
downtimeINTERVALThe sum of all the dead ranges in the aggregate.