Define SLIs SLOs and error budgets
Define SLIs SLOs and error budgets
A service level indicator (SLI) measures a user-visible property such as successful eligible requests divided by all eligible requests. A service level objective (SLO) sets a target for that indicator over a defined window. The error budget is the allowed fraction of bad events, 1 minus the target. Define eligibility, treatment of timeouts and missing telemetry before measuring; an empty denominator is unknown, not perfect availability.
package main
import ( "fmt")
func main() { total, bad := 10000, 8 allowed := total / 1000 fmt.Printf("SLI %.2f%%\n", 100*float64(total-bad)/float64(total)) fmt.Println("remaining", allowed-bad)}For a 99.9% request-success objective and 10,000 eligible events, at most ten bad events fit the budget. Eight have occurred, leaving two for this fixed set. A rolling window changes both counts; it is not a permanent allowance. Avoid confusing request-based budget with minutes of downtime.
Expected output:
SLI 99.92%remaining 2Calculate burn rate and handle missing samples
package main
import ( "fmt")
func burn(total, bad int) (float64, bool) { if total <= 0 || bad < 0 || bad > total { return 0, false } return (float64(bad) / float64(total)) / 0.001, true}func main() { v, ok := burn(1000, 5) fmt.Printf("%.0fx %t\n", v, ok) _, ok = burn(0, 0) fmt.Println(ok)}A rate of five means the observed bad fraction is five times the allowed fraction, not that exactly five budgets have already been spent. Use multiple measurement windows and minimum traffic checks for alerting. Set explicit policies for releases when the budget is exhausted.
Expected output:
5x truefalseTry it locally
For 2,000 eligible requests and 6 failures, compute remaining whole-event budget for 99.9% and indicate whether the budget is exceeded.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Reliability and observability 05: Define SLIs SLOs and error budgets
Check the lesson objective before moving on.
Which denominator fits a request-success SLI?
What does a zero denominator mean?