Observability & Monitoring

Monitoring tells you that something is wrong; observability lets you find out why, including for failures nobody predicted. Both rest on three kinds of telemetry — metrics, logs and traces — turned into dashboards that answer questions and alerts that wake people only when they must. This lesson covers each signal, what to measure, and how to keep alert noise low. For database-specific signals, see DBA: Monitoring & Operations.

The Three Signals

Each kind of telemetry answers a different question at a different cost. Healthy systems use all three and link them together.

Observability pillars: metrics, logs, and traces correlated into dashboards and SLO alerts

Figure: Metrics, structured logs, and distributed traces correlated via trace IDs to drive SLO-based alerts.

Metrics, Logs and Traces

SignalWhat it isBest forCost driver
MetricsNumbers sampled over time, with labels.Trends, dashboards, alerting.Number of distinct label combinations.
LogsTimestamped records of discrete events.Details of a specific error or request.Volume of data ingested and retained.
TracesThe path of one request through many services, as timed spans.Latency breakdown across services.Number of spans; usually sampled.

OpenTelemetry is the vendor-neutral standard for producing all three: instrument once, then send the data to whichever backend you choose. Correlate the signals by putting the same trace ID in log records and by linking dashboards to the logs and traces of the same time range.

Monitoring vs Observability

Monitoring checks known failure modes: disk full, error rate high, certificate expiring. Observability is the property of a system that lets you ask new questions of its telemetry without shipping new code — “are the slow requests all from one customer, one region, one build?” It requires rich, high-cardinality context such as customer ID, build version and endpoint on events and traces. You need both: monitoring to be told, observability to understand.

Metrics

Metrics are cheap to store and fast to query, which makes them the backbone of dashboards and alerts. Prometheus, with its pull model and query language PromQL, is the most widely used open-source metrics system.

What to Measure: RED and USE

Two short checklists cover most needs. For every service, measure RED: Rate (requests per second), Errors (failed requests per second) and Duration (latency distribution). For every resource — CPU, memory, disk, network, connection pool — measure USE: Utilization, Saturation (queued work) and Errors. Google's SRE book summarizes the user-facing view as the four golden signals: latency, traffic, errors and saturation.

Counters, Gauges and Histograms

A counter only increases (requests served) and is queried as a rate; a gauge goes up and down (memory in use); a histogram counts observations in buckets, so latency percentiles can be computed across many instances. Avoid averages for latency: an average of 100 ms can hide the 5% of users who wait three seconds.

# PromQL: requests per second over 5 minutes, by service
sum by (service) (rate(http_requests_total[5m]))

# Share of requests that failed with a 5xx status
sum(rate(http_requests_total{status=~"5.."}[5m]))
  / sum(rate(http_requests_total[5m]))

# 95th percentile latency from a histogram, by service
histogram_quantile(0.95, sum by (le, service) (rate(http_request_duration_seconds_bucket[5m])))

Control Cardinality

Every distinct combination of label values is a separate time series. A label such as user_id or a raw URL path with IDs in it can create millions of series and overwhelm the metrics system. Keep metric labels to bounded sets — status code, endpoint template, region — and put unbounded identifiers in logs and traces instead.

Logs and Traces

When a metric shows that something is wrong, logs and traces show the specific requests involved.

Structured Logging

Write logs as structured records (usually JSON) with consistent field names, rather than free-form sentences, so they can be filtered and aggregated:

{"ts":"2026-11-14T09:41:07.213Z","level":"error","service":"checkout","version":"2.4.1",
 "trace_id":"4bf92f3577b34da6a3ce929d0e0e4736","route":"/api/orders","status":502,
 "duration_ms":3012,"msg":"payment provider timeout","provider":"acme-pay"}

Log at the right level: error for failures that need attention, warn for degraded but handled situations, info for significant business events, debug only when enabled temporarily. Never log secrets, tokens or full personal data, and set retention by need and law rather than keeping everything forever.

Distributed Tracing

A trace follows one request across services. Each service records a span with its start, duration and attributes, and passes the trace context to the next service in a header (the W3C traceparent header). A trace view then shows, for example, that a slow checkout spent 2.8 of its 3 seconds waiting for the payment provider. Tracing every request is expensive at scale; sample a percentage, and keep all traces for errors and very slow requests.

Dashboards

A dashboard should answer a question for a specific audience. A wall of fifty unlabeled charts answers none.

Design for Questions

  • Service overview (for on-call): SLO status and error budget, RED metrics, saturation of the main resources, and recent deployments as annotations.
  • Dependency view: the health of each upstream and downstream dependency, so the first question — “is it us or them?” — is answered at a glance.
  • Capacity view (for planning): long-range trends of traffic and resource use.

Put the most important charts at the top, show units and thresholds, use the same time range across charts, and keep dashboards in version control as code (for example, Grafana dashboards as JSON) so they are reviewed and survive tool migrations.

Alerting Without Noise

Alert fatigue is a reliability risk: a team paged ten times a night for nothing will eventually miss the page that matters. Every alert must earn its place.

Alert on Symptoms and Burn Rate

Page on symptoms users feel — errors, latency, unavailability — rather than on causes such as high CPU, which may be harmless. The most robust form is an SLO burn-rate alert: page when the error budget is being consumed much faster than the SLO allows, measured over both a long and a short window so it fires quickly and stops quickly.

# Prometheus alerting rule: page when the 99.9% SLO's budget burns 14.4x too fast.
groups:
  - name: checkout-slo
    rules:
      - alert: CheckoutErrorBudgetBurn
        expr: |
          (
            sum(rate(http_requests_total{service="checkout",status=~"5.."}[1h]))
              / sum(rate(http_requests_total{service="checkout"}[1h]))
          ) > (14.4 * 0.001)
          and
          (
            sum(rate(http_requests_total{service="checkout",status=~"5.."}[5m]))
              / sum(rate(http_requests_total{service="checkout"}[5m]))
          ) > (14.4 * 0.001)
        labels:
          severity: page
        annotations:
          summary: "Checkout is burning its 30-day error budget 14x too fast"
          runbook_url: "https://runbooks.example.org/checkout/error-budget-burn"

A burn rate of 14.4 sustained for one hour consumes 2% of a 30-day budget; the five-minute condition makes the alert clear soon after the problem stops. Use slower burn rates over longer windows for ticket-level alerts.

Reduce Alert Noise

  • Require a condition to hold for several minutes (for:) before firing, to ignore brief spikes.
  • Group related alerts and suppress dependent ones: one alert for “database down”, not fifty for every service that uses it.
  • Route by severity: page for user impact now, ticket for things that need attention this week.
  • Attach a runbook link to every alert, and review alerts monthly: delete those that never led to action, and fix the noisiest.
  • Monitor the monitoring: alert if metrics stop arriving, so silence never means “all good” by accident.

Practice Lab

Run Prometheus and Grafana locally with containers, scraping a small instrumented application or the Prometheus node_exporter.

Instrument and Visualize

  1. Expose a request counter and a latency histogram from a small web application.
  2. Build a service overview dashboard with rate, error ratio and 95th percentile latency, plus a deployment annotation.
  3. Generate load with a few errors and slow requests, and find a slow request's trace ID in the logs.

Design Alerts

  1. Write an SLO for the application and a burn-rate alert like the one above, with a runbook link.
  2. Inject errors at 5% for ten minutes and check that the alert fires and then clears.
  3. Write a CPU-based alert as well, explain why it would be noisier, and decide whether it should page or create a ticket.