Metrics and logging system design (Datadog-style): series, roll-ups and alerts you can trust
How to design a Datadog-style metrics and logging platform in real interview order: series and log bytes as the numbers that matter, batched ingest that answers 202 only once durable, agents, intake, a durable log, writers, a tag index and a compressed time-series store built in passes, one point walked from a counter to a graph and a page, a lab on tags, cardinality and churn, a lab on roll-up tiers and how much of your logs to index, a lab on alerting when data arrives late, and what happens when the monitoring system itself fails.
The 1-minute answer
How this page follows the interview
Each phase is a section below, in the order you'd present it. Click a phase for what to say, what to write, and the trap.
New to metrics, logs, SLOs or stream pipelines? Foundations F14 (observability and safe deployments), F10 (queues and event streams) and F17 (data pipelines, windows and late data) cover the ideas this page builds the system for.
Requirements and numbers
Agree what's collected and what's promised, then size it. Two numbers matter more than requests per second: how many series exist, and how many log bytes you index. Change any input: each number comes with the decision it forces.
Functional
- Agents send metrics and logs from every host
- Graph metrics by tag, over any time range
- Search recent logs; keep old ones
- Monitors: alert on thresholds, notify people
- Many tenants (customers), each with quotas
Non-functional
- A 202 is never lost
- Queryable within seconds of arriving
- Alerts within a minute or two, never false because of our lag
- Dashboards over a day in under 2 s
- One tenant can't slow another
Out of scope (say it)
Tracing and APM in depth, real-user monitoring, anomaly detection with ML, billing.
Capacity calculator
Every input is an assumption 🔶: say it out loud. Anchors: DogStatsD flushes every 10 s ✅ Datadog docs; Gorilla compresses to 1.37 bytes a point ✅ Gorilla 2015; Prometheus averages 1–2 bytes a sample ✅ Prometheus docs. Host and series counts are teaching values; Datadog hasn't published its totals.
- A day is 86,400 seconds; metrics arrive on a timer, so the peak is hosts, not users.
- Series, not requests. Points/s = series ÷ interval; series = metric names × tag combinations.
- Replicas count. Stored bytes × 3, and the durable log holds hours on top.
Core entities and the API
Agents push batches; users query, search and set monitors. What they listen for: batched, compressed ingest that answers 202 only once durable; queries the server down-samples; monitors with an evaluation delay.
| Entity | Key fields | Note |
|---|
How a graph picks its resolution
A graph never pulls raw points for a year. Pick a time range and see which tier answers it, how many points are read and how many go back.
Why it works this way
- Tiers by age. Uber's M3 example keeps 10 s points for 2 days, 1-minute roll-ups for 30 days and 1-hour roll-ups for 5 years. ✅ Uber M3 2018
- Roll-ups keep parts. Sum, count, min and max per interval, so averages, totals and peaks stay exact. 🧭
- Percentiles need sketches. "The 99th percentiles of the subsets are not enough to know the global 99th percentile." ✅ DDSketch 2019
- One query, many series. M3 lets a single query touch up to 100,000 series; past that, aggregate first. ✅ Uber M3 2018
"Points a line can show" is a teaching value for a graph a few hundred pixels wide.
High-level design
Build it in passes and say why each box exists. Click any box to see what it does, what it owns, what's inside it and what you'd watch.
Walk one point, box by box
The checkout service counts a request on host web-17. Follow that count to a graph and to a page, then a log line down the other road, then a bad day when writers fall behind. Each step lights up the path and shows what goes over the wire, what's stored and how long it takes.
Arrows show who calls whom, and the numbers give the order. Replies go back along the same line. Step 1 happens inside the host, so it has no arrow.
What the agent does on every host
The agent is the cheapest place to cut volume and the most dangerous thing to ship, because it runs on every customer's machines. Six things it must get right:
Data and database choices
Three different shapes of data: an index that changes when a series is born, points that arrive every 10 seconds, and logs that are big and mostly never read. Each gets its own store.
| Data | Pick | Considered | Why not those |
|---|
The one rule to know: accept, log, then store
# Intake, for one batch from an agent.
# Illustrative; Datadog's own code isn't public.
def on_batch(api_key, batch):
tenant = keys.tenant(api_key) # 403 if unknown
if batch.size > LIMIT: return 413
for s in batch.series:
if not recent(s.points): s.reject("too old")
if new_series(tenant, s) and over_quota(tenant):
s.drop(); usage.count(tenant, "dropped")
log.append("metrics", key=(tenant, s.hash),
value=batch, acks="all") # replicated
return 202 # only now
# Writer, reading the log.
def on_record(rec):
for s in rec.series:
sid = hash(s.name, sorted(s.tags))
if not index.has(sid): index.add(sid, s.tags)
shard(sid).append(sid, s.points) # memtableIllustrative. The order is the point: check, write to the durable log, then 202; storage happens after. 🧭
How a point shrinks to ~1.4 bytes
- Raw is 16 bytes. A 64-bit timestamp and a 64-bit value. ✅ Meta 2017
- Times: delta of delta. Points come every 10 s, so the change in the gap is usually zero and costs a bit. ✅ Meta 2017
- Values: XOR with the last one. Slowly changing values share most bits; store only the ones that changed. ✅ Meta 2017
- Result. An average of 1.37 bytes per point, a 12× reduction, on Facebook's data. ✅ Gorilla 2015
More database questions
Deep dive: tags, cardinality and churn
A series is one metric name with one combination of tag values, so series = names × the product of each tag's values. Most tags are small and harmless; one tag with a million values, or one that changes on every deploy, can take the shared platform down. Pick a preset, then switch tags on and off.
What the platform builds
- Index every tag. An inverted index from each tag to series ids makes any filter two or three lookups. The price: each id is stored once per tag. ✅ Datadog 2024
- Cap new series at intake. Per tenant and per metric, with counted drops and an alert to the team. 🧭
- Ingest all, index some. Let tenants choose which tags stay queryable per metric. ✅ Datadog docs
- IDs go to events. Customer, user, request and pod belong in logs and traces. ✅ Loki docs
Numbers to quote
A series is a name + tag values, host included; cardinality "usually scales with the most granular or detailed tag". ✅ Datadog docs
Datadog's data grew 30× from 2017 to 2022; the new index cut query timeouts by 99% and handles 20× higher-cardinality metrics on the same hardware. ✅ Datadog 2024
Memory per series depends on the engine and isn't published for Datadog's; the 3 KB default is a teaching value. ❓ measure yours
Deep dive: storage tiers, roll-ups and logs
Metrics are cheap per point and expensive in time: raw points kept for months cost petabytes and make long graphs slow. Logs are expensive per byte: indexing all of them is most of the bill. Pick a preset, then change the tiers.
Logs: decouple ingest from index
- Ingest everything. Excluded logs are still ingested and visible live. ✅ Datadog docs
- Index the slice people search. Exclusion filters drop noisy patterns from the index. ✅ Datadog docs
- Count what you don't keep. Metrics generated from logs keep the trend of excluded logs. ✅ Datadog docs
- Archive all, rehydrate on demand. Re-index a time range and query from your own object storage, up to a billion events per view. ✅ Datadog docs
Numbers to quote
Uber M3 (2018): 6.6 billion series; aggregates 500 million metrics a second and persists 20 million a second. ✅ Uber M3 2018
Prometheus: two-hour blocks compacted in the background; disk = retention × samples/s × bytes per sample. ✅ Prometheus docs
Costs: hot storage at 10× object storage per TB, 5× log compression and 50 M points/s per query are teaching values. 🧭 set your own
Deep dive: alerts you can trust on late data
A point stamped 10:00:00 might arrive at 10:00:15, or at 10:15 if it comes from a cloud API, or at 10:09 if our own writers are behind. A monitor that checks the window ending now sees a hole and fires. Shift the window back (evaluation delay), or evaluate only up to the pipeline's watermark. The chart shows how much of each second's data has arrived, by age.
Teal: share of points with that age that have arrived (arrival delay = backlog + a random wait with the typical mean). Shaded: the window the monitor checks. Teaching model. 🧭
The rules this lab teaches
- Delay covers normal lag. Shift the window back by a little more than typical arrival delay. ✅ Datadog docs
- Ratios beat counts. Missing points remove both halves of errors ÷ requests; a count just looks low. Try "Error ratio" on the second preset. 🧭
- The watermark covers our lag. When writers fall behind, evaluate only complete windows and send one platform alert. 🧭
- Don't flap. Require the condition for at least two evaluation cycles. ✅ SRE book
Numbers to quote
CloudWatch metrics: Datadog recommends an evaluation delay of at least 900 s. ✅ Datadog docs
Late points: Datadog's metrics API refuses points more than 1 hour old; logs accept up to 18 hours. ✅ Datadog API docs
Alert latency target: under a minute from emission to firing in one third-party breakdown. ✅ third party
A monitor's lifecycle
Each monitor keeps a state per group (per host, per service). Click events to move it; ones that can't happen from the current state are disabled. Each event shows what fires across the system.
Datadog lists four monitor statuses: Alert, Warn, No Data and OK ✅ Datadog docs; muted is shown here as a state for clarity.
Edge cases interviewers love
Failure, monitoring and recovery
A monitoring system fails in the worst possible way: quietly, while its customers think they're fine. Click a box to take it down: red is the failed part, amber is its blast radius. Each answer covers impact, degraded mode, the alert, automatic and manual recovery, and how you'd trace it.
Tracing it back: a normal day vs writers 9 minutes behind
Seconds from the request being counted to it showing on a graph. In the slow trace intake still says 202 in milliseconds; the point just waits in the durable log.
How one failure becomes three
What you'd alert on (SLOs)
| Signal | Target | Alert |
|---|
Incident playbook
The toolkit
Name the technique, then say where it goes in this design.
Making it fast, and who owns what
Each hop takes milliseconds; the flush interval, the evaluation delay and any backlog decide how fresh things are. Bars are sizing estimates, not measured figures.
| Team | Owns | Paged when… |
|---|
Senior follow-ups beyond the happy path
Interviewers pick from these themes once the design is on the board. Have one concrete answer per theme, tied to this design.
Practice ladder
Real interviews go level by level. Answer out loud before opening each one. Levels 6–7 are where Senior becomes Staff.
Sources
- Timeseries indexing at scale, Datadog engineering (28 Jun 2024)
- Evolving our real-time timeseries storage again: built in Rust for performance at scale, Datadog engineering (4 Aug 2025)
- Introducing Husky, Datadog's third-generation event store, Datadog engineering (17 May 2022)
- Computing accurate percentiles with DDSketch, Datadog engineering (23 Sep 2019)
- 2023-03-08 incident: a deep dive into our incident response, Datadog engineering
- 2023-03-08 incident: infrastructure connectivity issue affecting multiple regions, Datadog
- DogStatsD data aggregation, Datadog docs (checked Oct 2026)
- Submit metrics (v2 series), Datadog API docs (checked Oct 2026)
- Send logs, Datadog API docs (checked Oct 2026)
- Custom metrics billing, Datadog docs (checked Oct 2026)
- Metrics without Limits, Datadog docs (checked Oct 2026)
- Logging Without Limits guide, Datadog docs (checked Oct 2026)
- Rehydrating from archives, Datadog docs (checked Oct 2026)
- Adjusting No Data alerts for metric monitors, Datadog docs (checked Oct 2026)
- Monitor status, Datadog docs (checked Oct 2026)
- Gorilla: a fast, scalable, in-memory time series database, Pelkonen et al., VLDB 2015
- Beringei: a high-performance time series storage engine, Engineering at Meta (3 Feb 2017)
- Monarch: Google's planet-scale in-memory time series database, Adams et al., VLDB 2020
- M3: Uber's open source, large-scale metrics platform for Prometheus, Uber engineering (7 Aug 2018)
- Storage, Prometheus docs (checked Oct 2026)
- Labels and cardinality, Grafana Loki docs (checked Oct 2026)
- Practical alerting from time-series data, Google SRE book
- Metrics monitoring problem breakdown, Hello Interview (third party, used to cross-check interview expectations)
Checked October 2026. Architecture details are from Datadog's engineering blog (timeseries indexing, June 2024; the Rust real-time storage engine, August 2025; Husky, May 2022; DDSketch, September 2019; the March 2023 outage postmortems) and Datadog's docs (DogStatsD aggregation, the metrics and logs submission APIs, custom metrics billing, Metrics without Limits, Logging Without Limits, rehydration, no-data and evaluation-delay guidance). Compression and scale come from papers and posts by other companies: Facebook's Gorilla (VLDB 2015) and Beringei (2017), Google's Monarch (VLDB 2020), Uber's M3 (2018), plus the Prometheus and Grafana Loki docs. Datadog hasn't published its totals (hosts, series, bytes per day), queue layout, monitor scheduler or storage costs; those are tagged as inferred or interview choices, and the labs use rounded teaching values. Hello Interview is a third-party prep site, used only to cross-check what interviewers expect.
System Design Mastermind · Platform & Infra
Series homeAll of Platform & Infra
5 published · 7 comingWhat Senior platform loops lean on.
Distributed job scheduler system design: on time, at least once, never lost
Jobs in a sharded store with a precomputed next_run_at → one scheduler per shard (lease + fencing token) claims due jobs every second: insert run (unique job_id + time) and advance next_run_at in one transaction → durable queue with deliver-at, enqueued a little early → workers lease runs, heartbeat, call the target with the run id as idempotency key → backoff, then a DLQ. At-least-once, made safe by idempotency.
Metrics and logging system design (Datadog-style): series, roll-ups and alerts you can trust
Agents add up metrics for 10 s and batch them with logs → intake checks key and quotas, appends to a durable log, then 202 → writers map tags to series ids in an inverted index and store compressed points with roll-ups → logs: index a slice, archive all → monitors evaluate a window that ends in the past, and the whole stack is watched from outside.
Kafka system design: a distributed log that never loses an acknowledged message
Topics split into partitions; the producer hashes the key, batches and sends to the partition leader → the leader appends to the page cache, followers in other zones pull, acks=all waits for every in-sync copy (RF 3, min ISR 2) → consumer groups pull from offsets and commit them → KRaft controllers move leaders; tiered storage keeps history.
Ad click aggregator system design: exactly-once counts, late clicks and hot ads
Signed click URL → click service appends to Kafka and 302s → Flink dedupes by click id, counts per ad in 1-minute event-time windows, upserts (ad, minute) rows into an OLAP store → a per-click counter paces budgets → a nightly recount from raw clicks is what billing reads.
Payment system design (Stripe): idempotency, unknown outcomes, the ledger and reconciliation
Card → vault → token; confirm with an Idempotency-Key → attempt row written before the bank call → gateway with timeouts and breakers → result + outbox in one commit → event log → append-only double-entry ledger and signed webhooks → a timeout is 'unknown', resolved by status check and the next day's settlement file → payouts from balances.