Platform Engineering · Lesson 173

Engineering Metrics: KPI, KRI, OKR, SLA, SLI, SLO

Engineering organisations measure themselves with a pile of acronyms that are easy to confuse and costly to misuse. An OKR sets a goal; a KPI tracks how the business is performing; a KRI warns that a risk is growing; an SLI measures what users experience; an SLO sets the target for it; an SLA is a contract with consequences. This lesson follows one reliability problem from a quarterly objective to a funded decision, and shows how each measure helps, and the two classic mistakes: measuring the wrong thing, and promising customers more than you aim for.

Difficulty: Intermediate · Know this first: Lesson 172, Lesson 171

Run it as:

When it breaks, I check

One thing to remember

Where the time goes

This bar splits the time from the first failures to a funded fix, in days. It is a worked example, not a measurement. The KPI and SLA hops are where the wrong measures add weeks.

Try it: how big is the budget, and how fast is it going?

Set the SLO target, the daily request volume, and today's error rate. The window is 28 days. The burn rate says how many times faster than allowed the budget is being spent.

budget = 1 − target · full-outage minutes = 28 × 1,440 × budget · burn rate = error rate ÷ budget · days to exhaust = 28 ÷ burn rate

40minutes of budget
56,000failed requests allowed
2.0burn rate
14days until spent

Burning: the budget will run out in two weeks

Check yourself

Three questions. No score is saved anywhere — this is just you against the material.

Basic to master

Engineering metrics grow in four levels: first the definitions, then writing good SLIs and SLOs, then error budget policy and KRIs, and finally a small, connected set of measures for an organisation.

Basic — Six acronyms, six purposes

At the basic level you can tell the measures apart.

  • OKR: objective and key results, direction for a period.
  • KPI: key performance indicator, how the business or team is doing.
  • KRI: key risk indicator, how exposed you are to a risk.
  • SLI: service level indicator, a measure of user experience.
  • SLO: service level objective, the target for an SLI.
  • SLA: service level agreement, a contract with consequences.

Try it: Basic

A team's SLO is "99.9 percent of API requests succeed over 28 days". What is the SLI?

Now do it: Write one SLI and one SLO for a service you know, in the form good ÷ valid, target, window.

Intermediate — Good SLIs and SLOs

At the intermediate level you write indicators that match user experience.

  • Pick user journeys first (sign in, search, checkout), then one or two SLIs each: availability and latency.
  • Measure at the load balancer or edge, or with synthetic probes for low-traffic paths.
  • Exclude invalid events explicitly (client errors you cannot fix, health checks).
  • Set the target from history and need; start a little below current performance and tighten later.

Try it: Intermediate

A latency SLI is "average response time under 300 ms". What is wrong with it?

Now do it: Rewrite one average-based latency target you know as a "share of requests under X" SLI.

Advanced — Budget policy and KRIs

At the advanced level measures change what teams do.

  • An error budget policy agreed with product: what happens at 50, 75, and 100 percent spent (more review, slower releases, feature freeze for reliability work).
  • Multi-window burn-rate alerts: page on fast burn (for example 14.4 over 1 hour with a 5-minute check), ticket on slow burn.
  • KRIs with thresholds: certificate expiry, patch age, single points of failure, backup restore age, on-call load.
  • SLAs mapped to stricter SLOs, with the gap documented.

Try it: Advanced

The error budget is exhausted ten days into the window. What does a good error budget policy say?

Now do it: Draft a three-line error budget policy for one service and who signs it.

Master — A small, connected set of measures

At the master level an organisation measures a few things well, and they connect.

  • OKRs whose key results use SLOs and delivery measures (such as the DORA metrics), not activity counts.
  • A handful of KPIs per area, KRIs reported to risk and audit, and SLOs per critical journey.
  • Guard against Goodhart's law: when a measure becomes a target, people optimise the measure. Pair measures (speed with quality) and review them with judgement.
  • Prune: retire measures that never changed a decision.

Trade-off: more measures look thorough and dilute attention; fewer measures focus attention and miss some risks, which KRIs and reviews must catch.

Try it: Master

A team is told to raise deploy frequency and starts splitting changes into trivial deploys, while change failures rise. What is the fix?

Now do it: For one measure your team is judged by, name the measure that should be paired with it.

Go deeper

An SLI, an SLO, and burn-rate alerts written down as code: Prometheus recording rules and alerts, using the multi-window approach from the Google SRE workbook.

SLI and burn-rate alerts for a 99.9 percent checkout SLO

groups:
  - name: checkout-slo
    rules:
      # SLI: share of checkout requests that failed, over several windows
      - record: checkout:error_ratio:rate5m
        expr: |
          sum(rate(http_requests_total{route="/checkout",code=~"5.."}[5m]))
          / sum(rate(http_requests_total{route="/checkout"}[5m]))
      - record: checkout:error_ratio:rate1h
        expr: |
          sum(rate(http_requests_total{route="/checkout",code=~"5.."}[1h]))
          / sum(rate(http_requests_total{route="/checkout"}[1h]))
      - record: checkout:error_ratio:rate6h
        expr: |
          sum(rate(http_requests_total{route="/checkout",code=~"5.."}[6h]))
          / sum(rate(http_requests_total{route="/checkout"}[6h]))
      - record: checkout:error_ratio:rate30m
        expr: |
          sum(rate(http_requests_total{route="/checkout",code=~"5.."}[30m]))
          / sum(rate(http_requests_total{route="/checkout"}[30m]))

      # page: 2 percent of a 30-day budget in 1 hour (burn rate 14.4)
      - alert: CheckoutErrorBudgetFastBurn
        expr: checkout:error_ratio:rate1h > 14.4 * 0.001 and checkout:error_ratio:rate5m > 14.4 * 0.001
        labels: {severity: page}
      # ticket: 5 percent of the budget in 6 hours (burn rate 6)
      - alert: CheckoutErrorBudgetSlowBurn
        expr: checkout:error_ratio:rate6h > 6 * 0.001 and checkout:error_ratio:rate30m > 6 * 0.001
        labels: {severity: ticket}

0.001 is the error budget of a 99.9 percent SLO. The short window in each alert makes it stop firing soon after the problem ends. Tools such as Sloth or Pyrra generate rules like these from a short SLO definition.

One time it broke

This is a composite of a failure pattern that keeps repeating; the numbers are illustrative. A company paid its largest customer service credits three months running while its reliability dashboard was green.

Timeline

  • Month 1A new enterprise contract promises 99.95 percent API availability. Engineering's SLO, set a year earlier, is 99.9 percent; nobody compares them.
  • Month 1 to 3Availability runs between 99.9 and 99.93 percent. The SLO is met every month; credits are owed every month.
  • Month 4Finance asks why credits keep appearing. The contract and the SLO are put side by side for the first time.

What changed after

Every SLA must reference an SLO at least as strict, reviewed by engineering before signature; the SLO for that API is raised to 99.97 percent with funded work to meet it, and new contracts default to 99.9 percent.

If you remember nothing else

Design exercise

Define the measures for a payments platform: the quarter's OKR, three KPIs, three KRIs, and SLIs and SLOs for its two most important journeys, with any SLA customers will see.

Clarifying questions to ask

Which journeys matter most to customers and revenue? What did the last year of incidents look like? What do contracts already promise? Which risks have auditors raised?

Rough sizing

Say 3 million payment attempts a day, 99.95 percent success historically, p95 latency of 600 ms, and enterprise customers asking for an SLA.

Shape of the answer

OKR: "payments customers can rely on" with key results on SLO attainment and change failure rate; KPIs: authorisation rate, revenue per day, lead time; KRIs: certificate expiry, critical vulnerability age, untested backups; SLIs: payment success at the edge, latency under 1 s; SLOs 99.95 and 99 percent over 28 days; SLA 99.9 percent with credits; burn-rate alerts and a signed budget policy.

Trade-offs to name

Stricter SLOs please customers and cost engineering time and features. An SLA wins deals and creates a financial liability. More KRIs cover more risk and dilute attention.

Saved on this device, in this browser.
Next in this series · Lesson 174
PagerDuty & Opsgenie

Lesson 171 gave you the incident. This lesson gives you the tool that wakes the person who has to fix it. PagerDuty and Opsgenie do one job: take an alert, find the one person who is on call right now, page them, wait for an…

Go to Lesson 174 →

Or browse the full course from the Lessons index.