1. 7-Check Rolling Average
Our rolling latency average for a health check covers that check and the six checks before it on the same service, so one service's history never bleeds into another's. From svc_health, list every check alongside its latency and that rolling average, services alphabetically and each service's checks oldest to newest.
Show the solutionHide the solution
SELECT
svc_name,
checked,
latency,
AVG(latency) OVER (
PARTITION BY svc_name
ORDER BY checked
ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
) AS rolling_avg
FROM svc_health
ORDER BY svc_name, checked