Measure what users feel
You learn about outages from users.
Say it like this
I want to know about an outage before users do, so every service emits rate, errors, latency histograms and saturation, and the pager fires on the user-facing symptom rather than on every internal cause.
Basic solution
Emit request rate, error rate, latency percentiles and saturation per service; alert on symptoms (SLO burn), not on every cause.
From instrumented request to page
Services export counters and histograms; a collector stores them with labels; dashboards aggregate across instances; alert rules page only on user-facing symptoms and ticket the rest.
How it works
- Each service instruments its request handlers. Instrumenting means the code that handles a request also increments a counter named by endpoint and status code, records the request duration into a histogram (a set of fixed buckets such as under 10 ms, under 50 ms, under 250 ms, with a count per bucket), and updates gauges that hold a current value such as queue depth, connection pool use and CPU.
- A collector scrapes or receives these series every 10 to 15 seconds. A series is one metric with one combination of labels (service, endpoint, region, instance); the collector stores each sample with its timestamp so the value can be graphed over time.
- Dashboards aggregate across instances: they sum the request counters of all instances to get a fleet-wide rate, divide the error counter by the request counter to get an error ratio, and merge the histogram buckets of every instance so p95 and p99 can be read for the whole service rather than per machine.
- Alert rules run every minute against the aggregated series. A rule is a condition plus a duration: error ratio above the SLO target for 5 minutes, p99 above the latency target, or saturation above 80% for 15 minutes. The duration stops a single bad minute from paging anyone.
- Rules are sorted into two kinds. A symptom rule (users are seeing errors or slowness) pages the on-call. A cause rule (a disk is filling, replication lag is rising) creates a ticket or posts to a low-priority channel, because it may become a symptom later but is not one yet.
- Every alert carries a link to a runbook (the written steps for that alert) and to a dashboard filtered to the same labels, so the responder opens the page already looking at the failing service and region.
The four golden signals
- Latency: how long requests take, as percentiles, kept separately for successful and failed requests because a fast error is not good news.
- Traffic: requests per second, messages per second, or whatever unit of demand the service has.
- Errors: the rate of failed requests, including the ones that returned 200 with wrong or empty content.
- Saturation: how full the scarcest resource is: CPU, memory, connection pool, queue, disk. It is the signal that predicts the other three.
Worked example
Notification system, 2,900 sends per second average
- Series count: 12 services × 20 endpoints × 5 status classes × 30 instances ≈ 36K counter series, plus histograms with 12 buckets each: 12 × 20 × 12 × 30 ≈ 86K series. Around 120K active series per region is a small Prometheus; one 8 GB node handles it with 15-day retention.
- Latency histogram buckets chosen for the submit API: 5, 10, 25, 50, 100, 250, 500 ms, 1 s, 2.5 s, 5 s. The SLO is p99 under 500 ms, so the 250 and 500 ms boundaries are where precision matters.
- Error-ratio alert: sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) > 0.001 for 5 minutes. At 2,900/s that is 2.9 failures per second sustained; a single provider timeout burst of 20 requests does not page.
- Saturation alert: SMS sender queue depth above 50K for 10 minutes. At 1,000 sends/s to the provider that is 50 seconds of backlog, enough to breach the 60-second transactional SLO soon.
- What is deliberately not paged: a single instance restarting, CPU at 70%, a provider 429 that the retry handles. Those are tickets.
- Scrape cost: 30 instances × 4K series × 1 sample per 15 s ≈ 8K samples per second, roughly 1 MB/s before compression. Negligible.
Variants and when each wins
Pull-based scraping (Prometheus)
- The collector polls each instance over HTTP on a fixed interval and reads its current counters. It wins when the collector can reach every instance directly, because a target that stops answering is immediately visible as missing data.
Push-based agents (Datadog, OpenTelemetry collector, StatsD)
- Each instance sends its samples to a local agent that batches and forwards them. It wins across network boundaries and for short-lived jobs that would be gone before a scrape, at the cost that "no data" and "a value of zero" look the same.
Logs-derived metrics
- Counts and timings are computed by querying the log store after the fact. It wins when you cannot change the code to add instrumentation; it loses on cost at volume and on the delay the log pipeline adds.
Managed metrics (CloudWatch, Cloud Monitoring)
- The cloud provider stores the series and bills per series. It wins for a few hundred series per service with zero operations; the bill grows fast once labels carry high-cardinality values.
Recommendation: Prometheus-style pull with OpenTelemetry instrumentation for services, a push agent for batch jobs, and never user ids or request ids as labels.
Failure modes
Alert on causes, page fatigue
- The on-call receives 40 pages a week and starts ignoring them, so the one that matters is missed. It happens because every threshold on every resource is wired to the pager. Page only on SLO-threatening symptoms, route cause alerts to tickets, and delete any alert that has not led to an action in 90 days.
Cardinality explosion
- The metrics store runs out of memory or scrapes start timing out. It happens because a label carries user id, request id or the full URL path, so every distinct value creates a new series and the count runs into millions. Allow labels only for bounded sets such as the endpoint template, the status class and the region, and cap the number of series one service may emit.
Averages on the dashboard
- Latency looks fine while users complain about slow pages. It happens because the graph shows mean latency, and the slow 1% of requests disappears inside the average. Record histograms, display p95 and p99, and alert on p99.
Alerting on a flapping signal
- Pages fire and resolve every few minutes. It happens because a threshold is applied to a noisy series with no duration, so every spike crosses it. Require the condition to hold for N minutes and evaluate a rate over a window rather than an instantaneous value.
Monitoring the monitor
- An outage passes with no alert at all because the collector itself was down. It happens when there is a single collector and nothing watches for silence. Add a heartbeat alert that fires when no data arrives, and run a second collector or a managed fallback for the alerting path.
Interviewer follow-ups
Answer out loud before you open each one.
Which signals would you alert on for the redirect service of a URL shortener?
Error ratio of redirects over 5 minutes, p99 redirect latency against the 50 ms target, and cache hit ratio dropping below a floor, because a falling hit ratio predicts database overload before latency moves. Saturation on the Redis connection pool would be a ticket, not a page.
Why histograms rather than storing every request duration?
Storing every sample at thousands of requests per second is too expensive and percentiles would need all samples to compute. A histogram with a dozen buckets is a fixed-size set of counters per endpoint that still lets you compute any percentile across instances by summing buckets.
How do you avoid high cardinality while still debugging a single user?
Keep metrics for aggregates with bounded labels and use logs or traces, which are keyed by request id, for individual requests. Exemplars can attach a trace id to a histogram bucket so you can jump from a slow bucket to one real trace.
What is the difference between a symptom alert and a cause alert?
A symptom alert fires on what users experience: errors, latency, missing results. A cause alert fires on an internal condition such as disk 90% full or replication lag. Page on symptoms because they are always worth waking someone for; causes become tickets unless they are about to become symptoms.
Connections
The same parts on other clouds
The diagrams above name AWS services as one concrete example. Every part has a close equivalent elsewhere. In an interview, name the role first, such as “a managed Redis cache”, then the product you would pick.
| AWS | Used here as | Google Cloud | Microsoft Azure | Open source and others |
|---|---|---|---|---|
| Amazon EC2 Auto Scaling | Service instances | Compute Engine managed instance groups | Virtual Machine Scale Sets | Kubernetes Deployment with a HorizontalPodAutoscaler, Nomad |
| Amazon CloudWatch | Metrics collector, Dashboards, Alert rules | Cloud Monitoring, Cloud Logging | Azure Monitor | Prometheus and Grafana, Datadog |