Where to start First steps track · 15 stages
Linux Labs

SLI and SLO — the share of good requests and the error budget

cheat sheet · Ubuntu 24.04 · nginx 1.24 · GNU awk 5.2 https://lab.dimsanych.ru/en/wiki/sli-slo/

Cheat sheet

  • combined + $request_time $msec: code $9, time $(NF-1), unix time $NF
  • lines from the last hour
  • awk -v f="$(date -d '1 hour ago' +%s)" '$NF >= f' access.log > w.log
  • availability SLI: share of responses without a 5xx
  • awk '$9 >= 500 {b++} END {printf "%.2f\n", 100*(NR-b)/NR}' w.log
  • p95 response time: nearest rank ⌈0.95 × N⌉
  • awk '{print $(NF-1)}' w.log | sort -n > /tmp/t
  • k=$(( ($(wc -l < /tmp/t) * 95 + 99) / 100 )); sed -n "${k}p" /tmp/t
  • error budget: SLO 99.5 % with 400000 requests in the window
  • awk 'BEGIN {print 400000 * (1 - 0.995)}' 2000 bad allowed
  • burn rate: 7 % errors at SLO 99.5 %
  • awk 'BEGIN {print 0.07 / (1 - 0.995)}' 14
Loading…