Skip to content
Visual explainer 2h to learn 3 steps

Observability, SLOs & error budgets

Define SLIs and SLOs and design metrics, logs and traces for a system.

By Invicly Tech, , in System Design Deep Dive. About 11 minutes to read.

Topic 21 of 33

In short

Observability is the ability to understand what a system is doing from its outputs. Metrics, logs and traces answer different questions, while SLOs and error budgets turn reliability into a clear rule for when to ship or slow down.

Explained simply

Observability means being able to look at a running system from the outside and understand what is happening inside, especially when something goes wrong. You get there by making the system report three kinds of signals: metrics, logs and traces.

Metrics are numbers over time, like requests per second or error rate. They are cheap and good for dashboards and alerts. Logs are written records of events, like a diary. Traces follow one request as it hops between services, showing how long each hop took. Each answers a different question.

To decide what good enough means, teams set an SLO (service level objective), a target like 99.9% of requests succeed within 300 ms over 30 days. The measurement behind it is the SLI (service level indicator). The SLA is the contract with customers, usually looser than the SLO and backed by refunds.

The gap between 100% and the SLO is the error budget. If you have budget left, ship features freely. If you have used it up, slow down and fix reliability. This turns endless arguments about speed versus stability into a simple, shared rule.

Press Play on a diagram to walk through it one step at a time.

CompareThree pillars of observability
Metrics
  • Numeric time series
  • Cheap, aggregated
  • Dashboards and alerts
  • Answers: is it broken?
Logs
  • Discrete event records
  • Rich detail, costly at scale
  • Structured JSON best
  • Answers: what happened?
Traces
  • One request across services
  • Spans with timings
  • Find slow hops
  • Answers: where is it slow?
CycleError budget loop
  1. 1
    Set SLO

    For example 99.9% successful requests

  2. 2
    Measure SLI

    Track success rate over 30 days

  3. 3
    Budget remains

    Ship features at full speed

  4. 4
    Budget spent

    Freeze risky releases, fix reliability

  5. Back to step 1
LayersA typical observability pipeline
  1. 1
    Instrumented apps

    OpenTelemetry SDKs emit metrics, logs, traces

  2. 2
    Collector

    OpenTelemetry Collector batches, samples, routes

  3. 3
    Storage backends

    Prometheus metrics, Loki logs, Tempo or Jaeger traces

  4. 4
    Dashboards and queries

    Grafana views linked by trace ID

  5. 5
    Alerting and on-call

    Burn-rate alerts page a person

In depth

Choosing good SLIs

A good SLI measures what users actually experience. The usual form is a ratio: good events divided by valid events. Availability: successful requests divided by all requests. Latency: requests faster than a threshold (say 300 ms) divided by all requests. For pipelines, freshness (data updated within 10 minutes) and correctness also work.

Measure as close to the user as practical: the load balancer logs are better than server metrics, because they include requests the server never saw. Exclude what you cannot control or should not count, like 4xx errors caused by bad client input, but be careful: a bug that returns 404 for real pages is your fault.

Define SLIs per user journey, not per server: checkout, search, login. A few meaningful SLOs (often 3 to 5 per service) beat dozens that nobody watches.

  • SLI = good events / valid events
  • Measure at the load balancer or client when you can
  • One SLO per important user journey

Error budgets and burn-rate alerts

A 99.9% SLO over 30 days allows 0.1% bad requests, or about 43 minutes of full downtime. The burn rate is how fast you are spending that budget: a burn rate of 1 uses exactly the whole budget in 30 days; a burn rate of 14.4 uses 2% of it in one hour.

Alerting on raw error rate is noisy. Google's SRE Workbook recommends multi-window, multi-burn-rate alerts. Page someone when 2% of the budget burns in 1 hour (burn rate 14.4) or 5% in 6 hours (burn rate 6). Open a ticket when 10% burns in 3 days (burn rate 1). Each alert also checks a short window (for example 5 minutes for the 1-hour alert) so it stops firing quickly once the problem is fixed.

Agree on an error budget policy in advance: what happens when the budget is spent, such as freezing feature releases until reliability work brings it back.

FlowFrom SLO to a page
  1. 1
    SLO 99.9% / 30 days

    Budget: 0.1% of requests

  2. 2
    Measure error ratio

    Over 1 h and 5 min windows

  3. 3
    Burn rate = ratio / 0.001

    1.44% errors is burn rate 14.4

  4. 4
    Both windows above 14.4?

    2% of budget gone in an hour

  5. 5
    Page on-call

    Slower burns open a ticket

Metrics: RED, USE and histograms

Two checklists help decide what to measure. For request-driven services, RED: Rate (requests per second), Errors (failed requests per second), Duration (latency distribution). For resources like CPUs, disks and queues, USE: Utilisation (how busy), Saturation (how much work is waiting), Errors. Google's four golden signals (latency, traffic, errors, saturation) combine the two.

Record latency as a histogram, not an average. Averages hide the slow tail that users complain about, and you cannot average percentiles across servers. With Prometheus histograms, you aggregate bucket counts first and compute percentiles afterwards with histogram_quantile.

Watch cardinality: every unique combination of label values is a separate time series. Labels like endpoint, status code and region are fine. Labels like user_id or request_id can create millions of series and overload the metrics system. Put those in logs and traces instead.

Logs that help at 3 a.m.

Write logs as structured JSON with consistent fields: timestamp, level, service, message, and context such as user_id, order_id and trace_id. Structured logs can be filtered and aggregated (all errors for order 77) instead of grepped.

Include the trace ID in every log line. That is what lets you jump from a slow trace to the exact log lines for that request across all services. Use levels with discipline: ERROR for things someone should look at, WARN for suspicious but handled, INFO for key business events, DEBUG off in production by default.

Logs are the most expensive signal at scale, because every line is stored and indexed. Control cost by sampling noisy success logs, keeping detailed logs for days and summaries longer, and never logging secrets, passwords, tokens or full card numbers.

Distributed tracing with OpenTelemetry

A trace records one request's journey. Each step is a span with a name, start time, duration, attributes and a parent span. Spans from all services share one trace ID, so a tracing backend like Jaeger or Grafana Tempo can draw the whole request as a waterfall and show which hop was slow.

The trace context travels with the request. The W3C standard header is traceparent, for example 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01: version, trace ID, parent span ID and flags. OpenTelemetry, the vendor-neutral standard for traces, metrics and logs, provides SDKs and auto-instrumentation that create spans and pass this header for common frameworks.

Tracing every request is costly, so systems sample. Head sampling decides at the start (keep 5% of traces). Tail sampling decides after the trace finishes, so it can keep all errors and slow requests, at the cost of buffering spans in a collector.

SequenceOne trace across three services
Gateway
Order service
Payment service
Database
  1. 1POST /orders, traceparent: trace T, span A
    Gateway to Order service: POST /orders, traceparent: trace T, span A
  2. 2INSERT order (span B, parent A)
    Order service to Database: INSERT order (span B, parent A)
  3. 3Charge, traceparent: trace T, span C
    Order service to Payment service: Charge, traceparent: trace T, span C
  4. 4OK after 820 ms (the slow hop)
    Payment service to Order service: OK after 820 ms (the slow hop)
  5. 5201 Created, total 900 ms
    Order service to Gateway: 201 Created, total 900 ms

Learn it in 3 short steps

About 40m each. Track them with a timer in your plan.

  1. 1
    Define SLIs and SLOs~40m
  2. 2
    Use error budgets for release decisions~40m
  3. 3
    Design metrics, logs and traces~40m

Key points

  • Alert on user-facing symptoms like errors and latency, not every CPU spike.
  • An error budget is 100% minus the SLO.
  • Propagate a trace ID through every service and log line.
  • Track the four golden signals: latency, traffic, errors, saturation.

Key terms

Tap a card to flip it. 0/5 known

Examples

text
SLI: requests with status < 500 and latency < 300 ms
     divided by all requests
SLO: 99.9% over rolling 30 days

Error budget = 0.1% of requests
  at 10M requests/month -> 10,000 bad requests allowed

Alert: burn rate > 14x for 1 hour -> page on-call

Defining an SLO and its error budget.

SLIs as Prometheus queries

Assume the service exports http_requests_total with a code label and a latency histogram http_request_duration_seconds. Step 1: availability SLI is the share of non-5xx requests over the window. Step 2: latency SLI is the share of requests faster than 300 ms, using the le="0.3" bucket (the histogram needs a bucket at exactly 0.3). Step 3: p99 latency for a dashboard aggregates buckets across instances first, then computes the percentile. Use these expressions in recording rules and burn-rate alerts.

text
# availability over 5 minutes
sum(rate(http_requests_total{job="api",code!~"5.."}[5m]))
  / sum(rate(http_requests_total{job="api"}[5m]))

# share of requests under 300 ms
sum(rate(http_request_duration_seconds_bucket{job="api",le="0.3"}[5m]))
  / sum(rate(http_request_duration_seconds_count{job="api"}[5m]))

# p99 latency
histogram_quantile(0.99,
  sum by (le) (rate(http_request_duration_seconds_bucket{job="api"}[5m])))

Using the error budget to make a release decision

The checkout SLO is 99.9% availability over 30 days, which allows about 43 minutes of full outage (30 x 24 x 60 x 0.001 = 43.2). Step 1: on day 12, a bad deploy caused 25 minutes of errors, and two smaller incidents cost 10 more. Step 2: 35 of 43 minutes are spent, leaving about 8. Step 3: a large database migration is planned for this week. Step 4: following the agreed policy, the team postpones the migration, ships only low-risk fixes, and adds an automatic rollback on error-rate spikes. When the window rolls forward and budget recovers, the migration goes ahead.

Quick reference

  • SLI = good events / valid events; SLO = target for it; SLA = contract with penalties
  • 99.9% over 30 days = about 43 minutes of downtime; 99.99% = about 4.3 minutes
  • Burn rate 14.4 for 1 hour spends 2% of a 30-day budget: page
  • RED for services (rate, errors, duration); USE for resources (utilisation, saturation, errors)
  • Use latency histograms; never average percentiles
  • Never put user_id or request_id in metric labels
  • Put trace_id in every log line; propagate the W3C traceparent header
  • Tail sampling keeps all slow and failed traces; head sampling is cheaper

Common mistakes

  • Paging on causes like high CPU instead of user impact.
  • Unstructured logs that cannot be searched or correlated.
  • Setting 100% SLOs, which leave no room to ship.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1An SLO is 99.9% over 30 days. Errors run at 1.44% for an hour. What is the burn rate?

Question 2

2Why should user_id not be a Prometheus metric label?

Question 3

3Which signal best shows which service made one specific request slow?

Question 4

4What is the main advantage of tail sampling over head sampling?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Compute the monthly (30-day) downtime allowed by SLOs of 99%, 99.9%, 99.95% and 99.99%.

  2. Exercise 2medium

    Write two SLOs for a photo upload feature: one for availability and one for latency. Say exactly what counts as good and valid, and where you measure.

  3. Exercise 3hard

    Write a Prometheus alert expression that pages when the 1-hour AND 5-minute error ratios both exceed 14.4 times the budget of a 99.9% SLO.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

What is the difference between monitoring and observability?
Monitoring watches for known problems with predefined dashboards and alerts. Observability is the broader ability to ask new questions about behaviour you did not predict, which needs rich, connected metrics, logs and traces.
Should my SLO be the same as my SLA?
No. Set the internal SLO stricter than the external SLA, so you notice and fix problems before you owe customers refunds.
Is OpenTelemetry a monitoring tool?
No. It is a standard and a set of SDKs and a collector for producing and shipping telemetry. You still need backends such as Prometheus, Jaeger, Tempo or a commercial vendor to store and view the data.
Why is 100% a bad SLO?
It leaves no room for any change or failure, so every deploy becomes a risk to the target. Users also cannot tell 100% from 99.99%, because their own networks and devices fail more often than that.

Go deeper

ShareXLinkedInWhatsApp