Implementatie van SLO
Stel Service Level Indicators (SLI’s) en Service Level Objectives (SLO’s) vast en implementeer ze, inclusief foutbudgetten en waarschuwingssystemen. Gebruik dit bij het vaststellen van betrouwbaarheidsdoelen, het implementeren van SRE-praktijken of het meten van de prestaties van je dienst.
Licentie MIT
Bron wshobson/agents
Download zipImplementatie van SLO
Een raamwerk voor het vaststellen en implementeren van Service Level Indicators (SLI’s), Service Level Objectives (SLO’s) en foutbudgetten.
Doel
Stel meetbare betrouwbaarheidsdoelen vast met behulp van SLI’s, SLO’s en foutbudgetten om een evenwicht te vinden tussen betrouwbaarheid en innovatiesnelheid.
Wanneer gebruik je dit?
- Stel doelstellingen vast voor de betrouwbaarheid van de dienstverlening
- De door de gebruiker ervaren betrouwbaarheid meten
- Foutmarges instellen
- Maak SLO-gebaseerde waarschuwingen aan
- Houd de betrouwbaarheidsdoelen bij
SLI/SLO/SLA-hiërarchie
SLA (Service Level Agreement)
↓ Contract with customers
SLO (Service Level Objective)
↓ Internal reliability target
SLI (Service Level Indicator)
↓ Actual measurement
Wat zijn SLI’s?
Veelvoorkomende vormen van SLI
1. Beschikbaarheid SLI
# Successful requests / Total requests
sum(rate(http_requests_total{status!~"5.."}[28d]))
/
sum(rate(http_requests_total[28d]))
2. SLI-latentie
# Requests below latency threshold / Total requests
sum(rate(http_request_duration_seconds_bucket{le="0.5"}[28d]))
/
sum(rate(http_request_duration_seconds_count[28d]))
3. Duurzaamheid SLI
# Successful writes / Total writes
sum(storage_writes_successful_total)
/
sum(storage_writes_total)
SLO-doelen vaststellen
Voorbeelden van SLO’s voor beschikbaarheid
| SLO % | Uitval per maand | Uitval per jaar |
|---|---|---|
| 99% | 7,2 uur | 3,65 dagen |
| 99,9% | 43,2 minuten | 8,76 uur |
| 99,95% | 21,6 minuten | 4,38 uur |
| 99,99% | 4,32 minuten | 52,56 minuten |
Kies geschikte SLO’s
Denk eens na over:
- Verwachtingen van gebruikers
- Zakelijke vereisten
- Huidige prestaties
- De prijs van betrouwbaarheid
- Benchmarks van concurrenten
Voorbeelden van SLO’s:
slos:
- name: api_availability
target: 99.9
window: 28d
sli: |
sum(rate(http_requests_total{status!~"5.."}[28d]))
/
sum(rate(http_requests_total[28d]))
- name: api_latency_p95
target: 99
window: 28d
sli: |
sum(rate(http_request_duration_seconds_bucket{le="0.5"}[28d]))
/
sum(rate(http_request_duration_seconds_count[28d]))
Berekening van de foutmarge
Formule voor het foutbudget
Error Budget = 1 - SLO Target
Voorbeeld:
- SLO: 99,9% beschikbaarheid
- Foutmarge: 0,1% = 43,2 minuten per maand
- Huidige afwijking: 0,05% = 21,6 minuten/maand
- Resterend budget: 50%
Beleid inzake foutmarges
error_budget_policy:
- remaining_budget: 100%
action: Normal development velocity
- remaining_budget: 50%
action: Consider postponing risky changes
- remaining_budget: 10%
action: Freeze non-critical changes
- remaining_budget: 0%
action: Feature freeze, focus on reliability
Implementatie van SLO
Opnameregels voor Prometheus
# SLI Recording Rules
groups:
- name: sli_rules
interval: 30s
rules:
# Availability SLI
- record: sli:http_availability:ratio
expr: |
sum(rate(http_requests_total{status!~"5.."}[28d]))
/
sum(rate(http_requests_total[28d]))
# Latency SLI (requests < 500ms)
- record: sli:http_latency:ratio
expr: |
sum(rate(http_request_duration_seconds_bucket{le="0.5"}[28d]))
/
sum(rate(http_request_duration_seconds_count[28d]))
- name: slo_rules
interval: 5m
rules:
# SLO compliance (1 = meeting SLO, 0 = violating)
- record: slo:http_availability:compliance
expr: sli:http_availability:ratio >= bool 0.999
- record: slo:http_latency:compliance
expr: sli:http_latency:ratio >= bool 0.99
# Error budget remaining (percentage)
- record: slo:http_availability:error_budget_remaining
expr: |
(sli:http_availability:ratio - 0.999) / (1 - 0.999) * 100
# Error budget burn rate
- record: slo:http_availability:burn_rate_5m
expr: |
(1 - (
sum(rate(http_requests_total{status!~"5.."}[5m]))
/
sum(rate(http_requests_total[5m]))
)) / (1 - 0.999)
SLO-waarschuwingsregels
groups:
- name: slo_alerts
interval: 1m
rules:
# Fast burn: 14.4x rate, 1 hour window
# Consumes 2% error budget in 1 hour
- alert: SLOErrorBudgetBurnFast
expr: |
slo:http_availability:burn_rate_1h > 14.4
and
slo:http_availability:burn_rate_5m > 14.4
for: 2m
labels:
severity: critical
annotations:
summary: "Fast error budget burn detected"
description: "Error budget burning at {{ $value }}x rate"
# Slow burn: 6x rate, 6 hour window
# Consumes 5% error budget in 6 hours
- alert: SLOErrorBudgetBurnSlow
expr: |
slo:http_availability:burn_rate_6h > 6
and
slo:http_availability:burn_rate_30m > 6
for: 15m
labels:
severity: warning
annotations:
summary: "Slow error budget burn detected"
description: "Error budget burning at {{ $value }}x rate"
# Error budget exhausted
- alert: SLOErrorBudgetExhausted
expr: slo:http_availability:error_budget_remaining < 0
for: 5m
labels:
severity: critical
annotations:
summary: "SLO error budget exhausted"
description: "Error budget remaining: {{ $value }}%"
SLO-dashboard
Structuur van het Grafana-dashboard:
┌────────────────────────────────────┐
│ SLO Compliance (Current) │
│ ✓ 99.95% (Target: 99.9%) │
├────────────────────────────────────┤
│ Error Budget Remaining: 65% │
│ ████████░░ 65% │
├────────────────────────────────────┤
│ SLI Trend (28 days) │
│ [Time series graph] │
├────────────────────────────────────┤
│ Burn Rate Analysis │
│ [Burn rate by time window] │
└────────────────────────────────────┘
Voorbeeldzoekopdrachten:
# Current SLO compliance
sli:http_availability:ratio * 100
# Error budget remaining
slo:http_availability:error_budget_remaining
# Days until error budget exhausted (at current burn rate)
(slo:http_availability:error_budget_remaining / 100)
*
28
/
(1 - sli:http_availability:ratio) * (1 - 0.999)
Extra patronen en sjablonen
Meer gedetailleerde sjablonen en uitgewerkte voorbeelden vind je in references/details.md. Bekijk dat bestand voor de volledige patroonbibliotheek.
Bestanden
LICENSESKILL.mdSOURCE.mdreferences/details.md
Gerelateerde termen
- burn rate
- cardinality
- counter
- Datadog
- error budget
- gauge
- golden signals
- Grafana
- histogram
- label / tag
- Latency
- Loki
- metric
- MTBF
- MTTA
- MTTD
- MTTR
- percentile (p50/p95/p99)
- Prometheus
- PromQL
- RED method
- SLA
- SLA (Service Level Agreement)
- SLI
- SLI (Service Level Indicator)
- SLO
- SLO (Service Level Objective)
- Throughput
- uptime / availability (nines)
- USE method