interpolated_uptime()
Get the total time live from a heartbeat aggregate and predecessor
Since 1.15.0
Calculate uptime from a heartbeat aggregate, taking the heartbeat aggregate from the preceding interval to interpolate
values at the boundary. This checks when the last heartbeat in the predecessor was received and makes sure that the
entire heartbeat interval after that is considered live. This addresses the issue where uptime would consider the
interval between the start of the interval and the first heartbeat as dead.
Samples
Section titled “Samples”Given a table called liveness containing weekly heartbeat aggregates in column health with timestamp column date,
use this command to get the total interpolated uptime of the system during the week of Jan 9, 2022.
SELECT interpolated_uptime( health, LAG(health) OVER (ORDER BY date))FROM livenessWHERE date = '01-9-2022 UTC'Returns:
interpolated_uptime------------------- 6 days 23:56:05Arguments
Section titled “Arguments”The syntax is:
interpolated_uptime( agg HEARTBEATAGG, pred HEARTBEATAGG) RETURNS INTERVAL| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| agg | HeartbeatAgg | - | ✔ | A heartbeat aggregate to get the liveness data from |
| pred | HeartbeatAgg | - | The heartbeat aggregate for the interval before the one being measured, if one exists |
Returns
Section titled “Returns”| Column | Type | Description |
|---|---|---|
| interpolated_uptime | INTERVAL | The sum of all the live ranges in the aggregate, including those covered by the last heartbeat of the previous interval. |