Interview Prep/Monitoring & Observability/Alerting Strategy, SLOs & Runbooks

How would you alert on latency in a way that maps to an SLO?

IntermediateProductionAlerting Strategy, SLOs & Runbooks
Answer

Turn latency into a ratio: "fraction of requests slower than the threshold". With a histogram that has a bucket at the threshold:

1 - (
  sum(rate(http_request_duration_seconds_bucket{job="api",le="0.3"}[5m]))
  /
  sum(rate(http_request_duration_seconds_count{job="api"}[5m]))
)

That is the bad-event ratio, which plugs straight into burn-rate alerts. Alerting on "p99 > 300ms" instead is noisier and cannot be summed into a budget. Make sure a bucket boundary sits exactly on the SLO threshold.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Alerting Strategy, SLOs & Runbooks