An alerting system receives alerts from monitoring tools, deduplicates and groups them, decides who to page, and keeps a history. Its hardest requirement is that it must work best exactly when everything else is failing, because that's when alert volume spikes.
Ingest: 100,000 alerts a minute, none lost
100,000 a minute is about 1,700 per second on average, and incidents produce storms ten times that. "Without losing any" means three things:
- Acknowledge only after a durable write. Receivers are stateless and horizontally scaled. They return success only after Kafka has written the alert to all in-sync replicas (
acks=all, replication factor 3). - Senders retry. Sources keep a local buffer and retry until they get an acknowledgement. That's at-least-once delivery, so the next stage must be idempotent: dedupe on the alert's fingerprint and timestamp.
- Absorb storms. Kafka is the buffer, and processing can fall behind briefly without loss. Track consumer lag, because if it grows, pages arrive late.
Deduplication: key, window, state
- Key: a fingerprint, a hash of the alert's identifying labels, for example
alertname,service,instanceandseverity, sorted. This is how Prometheus Alertmanager identifies alerts. Exclude labels that change on every firing, like a current value. - Window: an alert stays "open" while it keeps firing. A repeat within the window updates
last_seenand a count instead of paging again. The alert closes when the source sends "resolved", or when it hasn't been seen for a timeout. A repeat interval (say 4 hours) re-notifies for alerts still open. - State: partition the Kafka topic by fingerprint, so one consumer owns each fingerprint and keeps its state in memory without distributed locks. Checkpoint that state to a compacted topic or Redis, so a replacement consumer can take over after a rebalance.
Correlation: from alerts to incidents
- Group by labels: alerts with the same
serviceandclusterwithin a short window become one notification. Alertmanager waits briefly (group_wait) to collect a group before sending it. - Use the dependency graph: load service dependencies from tracing or a service catalog. When the database and the six APIs that call it all alert within a minute, the upstream-most failing node is the probable cause, and the rest are symptoms.
- Inhibit symptoms: while "database down" is open, suppress "API error rate high" for its dependants (Alertmanager calls these inhibition rules). One page instead of seven.
Storage: hot, cold, retention
| Data | Hot (fast, expensive) | Cold (cheap) | Retention |
|---|---|---|---|
| Open alerts and incidents | In memory + PostgreSQL | Until resolved | |
| Alert history | PostgreSQL or Elasticsearch, indexed by service and time | Parquet files in object storage | 30 days hot, 1–2 years cold |
| Metrics | Time-series DB at full resolution | Downsampled rollups (5 min, 1 h) | 15 days raw, a year of rollups |
Partition history tables by day, so retention means dropping whole partitions, which is much cheaper than DELETE on a large table.
Monitoring the monitor
- Dead man's switch: an alert that always fires (the "Watchdog" alert in common Prometheus setups) is sent to an external service. If the heartbeat stops arriving, that service pages you through a separate path. Silence is treated as failure.
- Independent infrastructure: run the meta-monitoring in a different region, account or provider, so it doesn't fail together with the system it watches.
- Synthetic alerts: inject a test alert every minute and measure time from ingest to notification. That's your end-to-end health check.
- Degrade loudly, once: when ingest lag is high, mark data as incomplete, suppress "no data" alerts that the lag itself would cause, and send one page about the alerting system rather than hundreds of false ones.
Writing it up
For a formal design document or a design-round answer, use this order: problem and users; functional and non-functional requirements; numbers; API and data model; architecture diagram; deep dives (ingest durability, dedupe state, correlation); failure modes; trade-offs and what you'd do next. See running a design interview for the timing.
Interview checklist
- Acknowledge only after a durable, replicated write; senders retry; consumers are idempotent.
- Define the dedupe fingerprint, the window and who owns the state.
- Correlate by labels and the dependency graph; inhibit symptoms.
- Split hot and cold storage, with explicit retention.
- Monitor the monitor: dead man's switch on independent infrastructure.
Level 15: Alert Storm
Put this into practice against live traffic. Your progress in the game is saved in your browser.
Play level 15Further reading
- Alex Xu, System Design Interview: An Insider's Guide, volumes 1 and 2. Worked case studies in interview format.
- Martin Kleppmann, Designing Data-Intensive Applications (O'Reilly). The standard book on replication, partitioning and consistency.
- Site Reliability Engineering, Google's free book on running reliable systems.
- The Amazon Builders' Library: practical articles on timeouts, retries, caching and load shedding.
- The System Design Primer: a broad, community-maintained overview.