Skip to content
All problems

Design a metrics monitoring and alerting system

breadth · 45 min · senior/staff

Setting

Thousands of internal services emit numeric metrics (request rate, latency, error count) continuously. Engineers need dashboards over that data and want to be paged when a metric crosses a threshold — within minutes of it actually happening, not after the fact.

The ask

Design the system that ingests metrics from every service, stores them queryably over time, and evaluates alerting rules against them in near-real-time.

Constraints & scale

  • ~50M metric data points/sec ingested at peak, from ~100K hosts/containers
  • Dashboards need to query arbitrary time ranges and aggregations (sum, p99, rate) over the last minutes to the last year, with the oldest data acceptably coarser-grained
  • An alert must fire within ~1 minute of the underlying condition being true, and must not spam the same page ten times for one ongoing incident
  • The monitoring system itself failing must not go unnoticed — it needs to be observable independently of the systems it watches
  • Storage cost must not grow unbounded — old high-resolution data should be downsampled, not kept forever at full fidelity

What a strong answer covers

Requirements → estimates (ingestion volume, storage growth) → data model (time series storage, downsampling) → high-level diagram (ingestion, storage, query, alert evaluation) → 1–2 deep dives → trade-offs. Likely probes: the ingestion hot path at this write volume, downsampling/retention strategy, and alert deduplication.

A 45-minute plan

  1. 0-5 min · Requirements
  2. 5-10 min · Estimates/API
  3. 10-25 min · High-level
  4. 25-40 min · Deep dive
  5. 40-45 min · Wrap

What to cover, in order

  1. Requirements
  2. Estimates (ingestion volume, storage growth)
  3. Data model (time series storage, downsampling)
  4. High-level diagram (ingestion, storage, query, alert evaluation)
  5. 1–2 deep dives
  6. Trade-offs

Where the follow-up questions go

Pick one of these for your deep dive before the interviewer picks for you.

  • The ingestion hot path at this write volume
  • Downsampling/retention strategy
  • Alert deduplication

Key trade-offs

Decisions a strong answer weighs, and what pushes each one either way.

  • Push or pull collection. Pulling from each target gives you a built-in health signal, since a failed scrape is itself data, and needs service discovery and reachability. Pushing works through firewalls and from short-lived jobs, and a silent sender looks the same as an idle one. Large fleets often mix them.
  • Label cardinality. Rich labels such as customer id or request path make slicing easy. Each unique combination creates a new series, and index size and query cost follow the series count, not the point count. Decide which labels are allowed and cap the rest.
  • Where to aggregate. Rolling up at ingestion cuts storage and speeds common queries, and loses the ability to ask new questions of the raw points. Keeping raw data is flexible and costs money fast at 50M points a second. Keep raw for a short window and pre-aggregate for dashboards you know about.
  • Downsampling and percentiles. Averaging old data into coarser buckets is cheap, and an average of p99s is not a p99. Store histograms or sketches if you want percentiles to survive downsampling.
  • Alert evaluation freshness. Evaluating rules against the incoming stream is fast and needs its own capacity and state. Querying the store on a schedule is simpler and adds query latency and load. A one-minute target limits how late either can be.

Common mistakes

What goes wrong most often on this problem, and why it hurts.

  • Keeping all raw points forever. Storage grows linearly while almost nobody queries year-old data at full resolution.
  • Paging on every evaluation where the condition is true. One ongoing incident turns into dozens of pages. Alerts need state: pending, firing, resolved.
  • Putting the monitoring system inside what it monitors. If it shares a cluster, network or deploy pipeline with the services, it fails with them and says nothing. An independent heartbeat check is needed.
  • Ignoring missing data. A dead service emits no points, so "value over threshold" never fires. Decide how absence is treated.
  • Running alert rules as heavy dashboard queries. Hundreds of thousands of rules each scanning history will compete with users and miss the one-minute deadline.

Graded on

Requirements & scoping · Estimation · API & data model · High-level architecture · Deep dive · Scalability & performance · Reliability & consistency · Trade-offs · Operability · Communication & drive

Ready to run this one for real?

Try this problem free

Your first session is free. Sign in, and you land on this brief, ready to start.