TExcelTAD

Choosing SLIs

A service level indicator (SLI) is a number that says how well the service is doing from the user's point of view. The SRE workbook recommends one shape for nearly every SLI:

SLI = good events / valid events        (a ratio between 0 and 1, usually shown as a percentage)

"99.2% of valid checkout requests in the last hour succeeded" is an SLI. "CPU is at 80%" is not: users don't experience CPU, they experience slow or failed requests. The ratio shape matters because it makes every SLI comparable, lets you set targets like 99.9%, and turns directly into an error budget.

The SLI menu

Different kinds of service need different indicators. Pick the two or three that match what users of this service care about.

Service type SLI Good event Valid event
request/response (APIs, web) availability response not 5xx (and not a timeout) every request except health checks and requests the client got wrong
request/response latency served faster than a threshold, e.g. 300 ms every valid request
request/response quality served without degradation (full results, not the cached fallback) every valid request
data pipeline freshness data in the report is younger than 30 minutes every read of the report
data pipeline correctness output record matches a known-good check every checked record
batch job coverage record processed in the run every record that should have been
storage durability object still readable every object written

Latency is usually expressed as a threshold ratio ("99% of requests under 300 ms") rather than "p99 < 300 ms": both say similar things, but the ratio form adds up across instances and time windows, and it gives a budget. Latency SLOs from Histograms shows how to compute it from Prometheus histograms.

Valid events: what to leave out

The denominator decides what counts. Typical exclusions:

  • health checks and synthetic probes, which would dilute the ratio with easy requests;
  • client errors (most 4xx): a 404 for a page that doesn't exist is the service working correctly. Keep 429 Too Many Requests in if it's your own overload protection users hit, since users experience it as an outage;
  • requests from your own load tests (tag them with a header and filter them out);
  • traffic during announced maintenance, only if your SLA explicitly says so.

Every exclusion is a choice that can hide pain. Write each one down in the SLO document.

Where to measure

Measured at Sees Misses
application metrics exact status and latency per endpoint requests that never reach a healthy process (crashes, full queues, network)
load balancer / ingress logs everything that reached your edge, including backend crashes (as 502/503/504) DNS, CDN and client network problems
synthetic probes (blackbox exporter) the whole path from outside, even with zero traffic real user behaviour; only the probed paths
client telemetry (browser, mobile) what users really experienced needs instrumentation, data arrives late and noisy

The model sends the same 10,000 requests past each measurement point. One of the four backend pods crashes for 400 of them (the load balancer turns those into 502s), and a CDN outage drops 150 more before they reach the edge:

python · try it yourself
import random

rng = random.Random(7)
counts = {"app": [0, 0], "load balancer": [0, 0], "client": [0, 0]}   # [good, valid]

for i in range(10_000):
    cdn_down = 2000 <= i < 2150                 # requests lost before the edge
    pod_crashed = 5000 <= i < 5400 and rng.random() < 0.25   # 1 of 4 pods down
    app_error = rng.random() < 0.002            # rare 5xx from the code itself

    counts["client"][1] += 1
    if cdn_down:
        continue                                 # only the client notices
    counts["load balancer"][1] += 1
    if pod_crashed:
        continue                                 # LB answers 502; the app never saw it
    counts["app"][1] += 1
    ok = not app_error
    for point in ("app", "load balancer", "client"):
        counts[point][0] += ok

for point, (good, valid) in counts.items():
    print(f"{point:<14} valid {valid:>6}  good {good:>6}  SLI {good / valid:.3%}")
app            valid   9755  good   9731  SLI 99.754%
load balancer  valid   9850  good   9731  SLI 98.792%
client         valid  10000  good   9731  SLI 97.310%

The application looks almost perfect because it never sees the requests that failed before reaching it. The load balancer view catches the crashed pod; only client-side measurement catches the CDN outage. A common compromise is to compute SLIs at the load balancer (complete, cheap, server-side) and add synthetic probes for the paths the edge can't see.

Few SLIs, owned by someone

Start with availability and latency for the most important user journeys (log in, search, checkout), not one SLI per endpoint. Each SLI needs an owner who will look at it when it degrades. An SLI nobody acts on is just another graph.

Test yourself

Which is a good SLI for an API?

  1. Average CPU usage of the pods
  2. Share of valid requests answered without a 5xx in under 300 ms
  3. Number of pods running
  4. Memory of the database

In the model, why does the application-level SLI look better than the client-level one?

  1. The app is faster
  2. Requests that failed before reaching a healthy process are not counted by the app at all
  3. The client double-counts
  4. Random noise

Should 404 Not Found responses usually count as bad events?

  1. Yes, every non-200 is bad
  2. No, they usually mean the client asked for something that doesn't exist, so they are excluded from valid events
  3. Only on weekends
  4. Only for POST requests