Write an SLO in a declarative tool so teams do not hand-write burn-rate rules.
AdvancedScenarioSLOs and Error Budgets
Answer
Situation read → Hand-written multi-window burn-rate rules are error-prone. Generate them.
What I'd do →
- Use Sloth or Pyrra (or OpenSLO spec) to define SLOs as code.
- Generate recording rules and alerts in CI and deploy via GitOps.
version: "prometheus/v1"
service: "checkout"
slos:
- name: "requests-availability"
objective: 99.9
sli:
events:
error_query: sum(rate(http_requests_total{job="checkout",code=~"5.."}[{{.window}}]))
total_query: sum(rate(http_requests_total{job="checkout"}[{{.window}}]))
alerting:
name: CheckoutHighErrorRate
page_alert: {labels: {severity: page}}
ticket_alert: {labels: {severity: ticket}}
- Run
sloth generate -i slo.yaml -o rules.yamland review the output.
Why → Consistent, tested rules across teams with one input per SLO.
Interview tip → Mention the generated multi-window, multi-burn-rate alerts by name.
More on SLOs and Error Budgets
Your company has no SLOs. A VP asks you to introduce them. Where do you begin?BeginnerChoose an SLI for a REST API: availability measured at the pod, the load balancer, or the client?IntermediateThe product owner wants a 99.99% SLO for a service that depends on a database with 99.95% availability. What do you say?IntermediateThe error budget for the month is exhausted on day 18. What happens now?IntermediateLatency SLO: "99% of requests under 300 ms." How do you measure it correctly in Prometheus?IntermediateA service has 20 requests per hour overnight. One failure blows the SLO alert. How do you handle low-traffic services?Advanced