Medium · 13 steps · ~60 min
Design a metrics and monitoring system
Ingest millions of samples, keep dashboards snappy and wake humans only when it matters.
Design the system that watches everything else: thousands of hosts push numeric samples every few seconds, engineers query dashboards, and alert rules page on-call when something is wrong. It must absorb spikes, keep alerts firing while dashboards are slow, control cost as data ages, and not be brought down by one bad label.
Same problem as PrometheusDatadogGrafana
How it works
- Ingest: agents push batches of timestamped samples (write-heavy).
- Query: dashboards read ranges, repeatedly and in bursts.
- Alert: rules are evaluated continuously on the same data.
What you'll build
- The API and the series schema
- A buffered, batched write path
- A cache for dashboards and a separate consumer group for alerts
- A quota against cardinality bombs
- A design that survives losing a store node, a consumer and a cold cache
Steps
- 1Design the API
- 2Design the data model
- 3Handle 2,000 samples/sec
- 4Handle 50,000 samples/sec for $3,200
- 5Cardinality
- 6Dashboards at 60,000 requests/sec for $1,100
- 7Alert evaluation beside storage for $3,500
- 8Alert evaluation
- 9A label bomb sends 90,000 samples/sec for $900
- 10Retention and downsampling
- 11Lose a storage node
- 12Lose a stream consumer
- 13Dashboard cache restart