An Error Budget is the allowable unreliability derived directly from your Service Level Objective (SLO). If your SLO dictates 99.9% availability over a 30-day period, then the remaining 0.1% is your budget for "bad" events. Mathematically, 0.1% of 30 days translates to 43.2 minutes of unavailability. This budget isn't solely for downtime; it applies to any "bad" event your Service Level Indicator (SLI) defines, such as failed requests, requests exceeding latency thresholds, or data integrity issues. It's a precise, quantifiable amount of acceptable failure that the service can experience without violating its commitment to users.
Tracking the error budget involves continuously monitoring your SLIs to measure actual "bad" events against this predefined budget. As errors or unacceptable performance occur, they consume a portion of your budget. For example, if your SLI measures the ratio of successful requests, every failed request chips away at the budget. SRE teams use monitoring systems (like Prometheus, Grafana, or proprietary dashboards) to aggregate these bad events over the SLO period and display the remaining budget. Visualizing this as a "burn down" chart helps teams understand how much headroom they have left and predict when they might breach the SLO if the current trend continues.
While knowing the remaining budget is crucial, understanding the "burn rate" – the speed at which the budget is being consumed – is key for proactive incident response. A high burn rate indicates that the service is experiencing problems significantly faster than anticipated, potentially leading to an SLO breach well before the end of the period. Burn rate alerts are configured to notify teams when a substantial portion of the budget is consumed over a short timeframe (e.g., 5% of the total budget used in 1 hour, or 20% in 6 hours). These alerts are essential for enabling SREs to investigate and mitigate issues before a catastrophic failure or an official SLO violation occurs, ensuring reliability remains within acceptable bounds.
Key Takeaways
- Error budget is the inverse of your SLO, representing allowable unreliability.
- SLIs measure bad events that consume the error budget.
- Tracking visualizes the remaining budget, often as a 'burn down' chart.
- Burn rate is the speed at which the budget is being consumed.
- Burn rate alerts enable proactive incident response to prevent SLO breaches.
Code Example
groups:
- name: service-slo-alerts
rules:
- alert: HighErrorRateBudgetBurn
expr: |
sum(rate(http_requests_total{job="my-service",status!~"2xx"}[5m]))
/
sum(rate(http_requests_total{job="my-service"}[5m]))
> (0.001 * 6) # 0.1% budget, burning 6x faster than allowed (i.e., 0.6% error rate)
for: 5m
labels:
severity: page
slo_budget: "99.9%"
annotations:
summary: "{{ $labels.job }} is burning through its error budget quickly"
description: "The service {{ $labels.job }} is experiencing a sustained error rate that could breach its 99.9% SLO within hours. Current error rate is {{ $value | humanizePercentage }}"How this code works
This code defines a Prometheus alert named HighErrorRateBudgetBurn to identify when a service is consuming its error budget too quickly, signaling a potential breach of its 99.9% Service Level Objective (SLO). The alert aims to notify engineers proactively before the budget is completely exhausted. The central part is the expr field, which calculates the service's current error rate. It achieves this by taking the sum(rate(...)) of all non-2xx HTTP requests (errors) from my-service over the last five minutes and dividing that by the sum(rate(...)) of all requests from the same service in the same period.
The calculated error rate is then compared to a threshold: > (0.001 * 6). This is a crucial, subtle part. The 0.001 represents the allowed 0.1% error budget for a 99.9% SLO. Multiplying it by 6 means the alert triggers if the current error rate is six times higher than the long-term allowed average, indicating a rapid "burn rate" of the budget. The for: 5m ensures the elevated error rate is sustained for five minutes, preventing transient spikes from triggering the severity: page alert. Finally, labels like slo_budget: "99.9%" provide context, and annotations offer a clear summary and description for on-call engineers, including the actual {{ $value | humanizePercentage }} error rate.