Skip to content

Monitoring and Observability

Monitoring is asking questions you knew in advance. Observability is being able to ask questions you did not. In an interview the distinction matters less than the structure: what you measure, how you alert, and what you do when the pager goes off.

You observe a system with three signals: metrics (cheap aggregates over time), logs (discrete events with detail) and traces (the path of one request across services). You watch the four golden signals — latency, traffic, errors, saturation — per service and per dependency. You alert on symptoms users feel, not on causes, so every page has a runbook and a clear action. Reliability targets are SLOs with an error budget, and when the budget is spent you stop shipping features and fix reliability. Incidents follow a fixed shape: declare, assign an incident commander, communicate, mitigate, then write a blameless postmortem.

Signal Strength Weakness Cost
Metrics Cheap, aggregatable, good for alerts No per-request detail; cardinality explodes with labels Low per point
Logs Full detail, easy to add Expensive at volume, hard to aggregate High
Traces Shows where time went across services Sampling may miss the rare failure Medium

They are complementary. A good answer to “checkout is slow” uses all three: the latency metric says when, the trace says where, the log says why.

Cardinality is the trap: a label with unbounded values — user ID, request ID, raw URL — creates a time series per value and will take down Prometheus. Bound them: status code, route template, region.

For every service and every dependency:

  • Latency — track p50, p95 and p99, not the mean. Averages hide the users who are suffering.
  • Traffic — request rate, queue depth, bytes per second.
  • Errors — 5xx rate, failed jobs, timeouts, dependency errors.
  • Saturation — how full the constrained resource is: CPU, memory, connections, disk, queue.

Related frameworks: RED (Rate, Errors, Duration — request-driven) and USE (Utilisation, Saturation, Errors — resources). Name one and use it consistently.

Prometheus scrapes HTTP endpoints exposing metrics in a text format and stores them as time series identified by name plus labels. Being pull-based makes target health explicit.

a minimal exposition endpoint
# HELP http_requests_total Total HTTP requests.
# TYPE http_requests_total counter
http_requests_total{method="GET",route="/orders",status="200"} 15432
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{route="/orders",le="0.5"} 15398

Metric types: counter (only increases), gauge (up and down), histogram (bucketed, quantiles computed server-side and aggregatable), summary (client-side, not aggregatable).

error ratio over five minutes
sum(rate(http_requests_total{status=~"5.."}[5m]))
/
sum(rate(http_requests_total[5m]))

Grafana sits on top for dashboards and alert routing: Prometheus for metrics, Loki or Elasticsearch for logs, Tempo or Jaeger for traces.

Sentry captures exceptions with stack traces, grouping, release tags and breadcrumbs. What makes it useful: tag events with release, environment and tenant so a regression is visible by version; resolve on deploy rather than on silence, because a new issue after a release is exactly the signal; and sample noisy errors with rate limits, since unthrottled reporting can be an outage amplifier.

  • Alert on symptoms, not causes. “Checkout error rate above 2% for 5 minutes” pages. “CPU at 80%” does not — CPU is a cause and may be normal.
  • Every page must be actionable. If the response is “look and see”, it is a ticket.
  • Use severities. Page for customer impact, ticket for trends, dashboard for context.
  • Route by ownership to the team that can fix it.

An SLI is a measurement (“share of requests under 300 ms”). An SLO is a target for it (“99.9% over 28 days”). The error budget is what remains — 0.1% of requests, about 43 minutes of full downtime per 30 days.

It turns reliability arguments into arithmetic: budget healthy, ship faster; budget exhausted, freeze risky changes and fix reliability — instead of chasing an implicit 100% nobody can afford.

The numbers worth knowing: 99% ≈ 7.2 h/month, 99.9% ≈ 43 min/month, 99.99% ≈ 4.3 min/month, 99.999% ≈ 26 s/month. Each nine costs roughly an order of magnitude more engineering.

A sustainable rotation has a primary and a secondary, an escalation path, runbooks per alert, compensation or time off in lieu, and a rule that whoever wrote the change is reachable.

An incident has a fixed shape:

  1. Declare early. Naming an incident is not an admission of failure.
  2. Assign roles — incident commander (decides), communications lead (updates stakeholders), subject-matter engineers (fix).
  3. Mitigate first, diagnose second. Roll back, flip the kill switch, fail over.
  4. Communicate on a cadence, even with nothing new; silence breeds duplicate work.
  5. Postmortem within days, blameless, with owned action items.
  1. A user says checkout is slow. Walk me through your first ten minutes.
  2. Which metrics would you alert on here, and why not CPU?
  3. Histogram versus summary — why does aggregation matter?
  4. How do you set an SLO with no historical data?
  5. What makes an alert good?
  • Dashboards without alerts, or alerts without runbooks. Observability theatre.
  • Averaging latency. The mean hides the tail, and the tail is where users churn.
  • Unbounded label cardinality. The most common way to kill a Prometheus instance.
  • Alerting on causes. CPU pages wake people for problems users never saw.
  • Promising 100% availability. Unachievable, and it makes every deploy a negotiation.