System Design · Interview breakdown · Free article
Design a Metrics Monitoring System (Datadog, Prometheus)
Notice a server that died, store 6.7 million samples a second in about a byte and a half each, keep one careless label from taking down every team, answer a 90-day question without averaging away the slow customers, and never page “resolved” for a service nobody can see. Built one step at a time, with experiments you can run.
A metrics monitoring system collects numbers from every server and service, stores them as time series, draws them on dashboards and pages an engineer when one crosses a line. Collectors pull each service’s /metrics page every 15 seconds from a target list, so a dead server shows up as a failed scrape, not as silence. Distributors check each team’s sample rate and hash every series to three ingesters. The ingesters refuse new series past each team’s limits, and keep the last hours in memory, compressed to about 1.37 bytes a sample, behind a write-ahead log. Every two hours the ingesters write immutable blocks to object storage, where a compactor merges the copies. Long charts read hourly recording rules and downsampled blocks that keep bucket counts and sums, never averages or percentiles. Rules run every 30 seconds; each alert on a service has a partner alert that fires when the service cannot be seen, and an always-firing heartbeat reaches a service on another provider that pages when it stops.
Difficulty: Hard. Reported in interviews at LinkedIn, Meta, Amazon, Stripe. Also asked as Design Datadog, Design Prometheus, Design a time series database, Design a metrics monitoring and alerting system.
How do you design a metrics monitoring system?
A metrics monitoring system collects numbers from every server and service, such as requests per second, errors and memory in use, stores them as time series, draws them on dashboards and pages an engineer when one crosses a line. Datadog sells one. Prometheus and Grafana are the open-source pieces most companies run. Collecting one number from one server is a cron job. Collecting 100 million numbers every 15 seconds is a different problem. Most of the numbers change very little. A single careless label can multiply them. And the system is most needed in the minutes when parts of it are failing too.
- Measured: checkout: 5xx = 1,027. Fifty thousand servers each expose about 2,000 numbers, and every one is read every 15 seconds.
- Collected: scrape 03:12:00 failed. A server that died must show up as a failure. Silence looks exactly like a quiet night.
- Stored: 1.37 bytes a sample. Nearly 7 million samples arrive every second, and the last two hours must stay in memory.
- Charted: p99, last 90 days. A 90-day chart must not read billions of samples, and must not average away the slow customers.
- Paged: checkout errors 8%. The page must not say resolved while data is missing, and must come even when monitoring is down.
Picture Ines, who is on call for the checkout service at an online shop. She never looks at most of the numbers the system stores. She looks at two dashboards and one pager. What she needs from the system is simple to say. When checkout breaks, the pager tells her within a minute or two. When she opens a chart, it shows what really happened. And when the system cannot see checkout at all, it says so, instead of saying everything is fine.
Interviewers like this problem because the first answer is short: agents send numbers, a time series database stores them, dashboards read them, and rules raise alerts. The rest of the round is about what that answer does under pressure. A server dies and nothing notices. The numbers arrive at millions a second. Someone adds the wrong label. The data an alert depends on stops arriving.
In brief, each service exposes its numbers on a /metrics page. Collectors, running Prometheus, read that page every 15 seconds from a list of targets. They forward the samples to distributors, which check each team’s sample rate and send every series to three ingesters. An ingester keeps the last two hours in memory, compressed, and writes a two-hour block to S3 when the time is up. Queriers read recent data from the ingesters and older data from the blocks. Grafana dashboards call them, and so does a rule evaluator that runs every 30 seconds. It sends firing alerts to an alert manager, which pages a person.
The rest of this page is about the moments that design has to survive.
The first is a quiet death. A worker’s machine dies at 03:11:53. If workers push their numbers, the system simply receives fewer of them, and a dead worker looks exactly like an idle one. Nothing pages.
The second is a label. At 16:00 on a Friday a developer adds the customer’s ID to one latency metric. It creates 21 million new series in an hour. Because series are spread evenly, every ingester fills at the same rate, and at 17:20 all hundred run out of memory together. Every team loses its metrics, checkout included.
What is the interviewer testing?
Most candidates reach a working answer quickly: agents or scrapers, a queue, a time series database, a query service with dashboards, and an alerting service. That answer is right, and a mid-level answer often stops there.
The interviewer then pushes on each piece. A server dies. Samples arrive at millions a second. One machine cannot hold them. A label explodes. Someone asks for 90 days. The data behind an alert stops. A senior answer pulls from a target list, compresses by series, shards by series hash with replicas, and downsamples. A staff answer also sets per-metric limits, keeps rollups that can be combined, and pairs every alert with one that fires when the system goes blind.
Spend most of the deep-dive time on storage, cardinality and alerting on missing data. How to run a round has the time plan for a 45 to 60 minute round and a 15-minute screen.
What should you ask before drawing anything?
Four questions change the design. Ask them in the first two minutes. If the interviewer leaves one open, say your assumption out loud.
- Whose machines are we watching?
- Assume our own fleet: about 50,000 servers and containers, in data centres and clusters the monitoring system can reach over the network. A product that monitors customers’ machines, like Datadog, changes how numbers arrive, and the answer says what changes.
- How fresh must an alert be?
- Assume a rule notices a sustained problem within a minute or two, and a page reaches the on-call engineer within a minute after that. Seconds are not needed; five minutes is too slow.
- How long do we keep the numbers?
- Assume every sample for 15 days, and a coarser version for 13 months, so a capacity review can compare this quarter with the same quarter last year.
- Logs and traces too?
- Assume numbers only. Logs and traces answer which request went wrong, and they get their own stores. The design links to them rather than storing them as metrics.
Functional requirements
1. Collect every server’s metrics every 15 s 2. Chart any series: last hour to 13 months 3. Rules → page the right team in 1 to 2 min group, route and silence alerts out: logs, traces, the paging app itself
Say it, don’t write it: Collecting is simple. The hard parts are knowing when something stopped reporting, and keeping one team’s numbers from drowning everyone else’s.
Two groups use the system. Engineers read it: they open dashboards, run queries and write alert rules. On-call engineers are woken by it, so what matters to them is whether a page is right. Services never use it directly. They only expose their numbers.
- Collect the metrics of every server and service every 15 seconds.
- Chart any series over any range, from the last hour to the last 13 months.
- Evaluate alert rules, and page the owning team within 1 to 2 minutes of a sustained problem, with grouping, routing and silences.
Out of scope
- Logs and traces, which have their own stores; the design links to them
- The paging product that rings a phone, which is a notification system of its own
- Anomaly detection and forecasting, beyond a note that they read the same series
- Billing customers for the numbers they send, beyond a short section on many teams
Non-functional requirements
• 50k targets × 2,000 = 100M series • Scrape every 15 s → 6.7M samples/s • Charts: last hour < 1 s, 90 days < 5 s • Keep raw 15 days, hourly 13 months • One team can never take the rest down • A page must not say resolved while blind
Say it, don’t write it: The series count sets the memory bill, not the sample rate, and the system must say when it cannot see.
- About 50,000 targets, each exposing about 2,000 series: 100 million series in all.
- Every series scraped every 15 seconds, so about 6.7 million samples arrive each second.
- A chart of the last hour answers in under a second, 1 s. A chart of 90 days answers in under 5 s.
- Every sample is kept for 15 days, and an hourly version for 13 months.
- One team’s mistake can slow or cut that team’s own metrics, and never anyone else’s.
- The system never reports a recovery it did not observe.
Two numbers are worth working out now, because each decides a piece of the design. The first is the write rate. 50,000 targets × 2,000 series is 100,000,000 series. Each is read every 15 seconds, so 100,000,000 ÷ 15 is about 6,666,667 samples a second, about 6.7 million. A database insert per sample would be 6.7 million inserts a second. So the design needs a store built for appending small numbers in time order, and the storage deep dive builds it.
The second is memory. Recent samples must be in memory, because most questions are about the last few hours. Facebook found that “at least 85% of all queries to ODS was for data collected in the past 26 hours” (Gorilla, VLDB 2015). Grafana’s capacity guide for Mimir, an open-source store built for this, budgets “2.5GB for every 300,000 series in memory” (Grafana Mimir). That is about 8,333 bytes a series. So a series costs memory for as long as it exists, whether it gets one sample or thousands. The number that decides the memory bill is how many series exist, and the design has to control it.
The other numbers appear in the deep dive that needs them. They are illustrative interview targets, not measurements of any real company’s fleet.
Core entities
Series = name + labels (its identity) Sample(series, time, value) Block(2 h: chunks + label index) Rule(query, for, labels) → Alert(state) Silence(matchers, reason, until)
Say it, don’t write it: A series is defined by its labels. Change one label value and you have a different series, with its own memory.
Follow one number through the records. Checkout pod 17 counts the requests that failed on the /pay route. Its /metrics page shows a counter named checkout_requests_total, with the labels route="/pay" and status_class="5xx", and the value 1027. The name and the labels together are a Series. The count, 1,027, read at 09:00:15, is a Sample of that series.
The ingesters keep each series’ recent samples in memory. Every 2 hours they write them out as a Block: compressed chunks of samples, plus an index from each label to the series that carry it. A Rule is a query with a threshold and a waiting time. While its query returns a result, it has an Alert with a state. A Silence mutes matching alerts for a while, with a reason and an end time.
| Record | What it holds | Why it is separate |
|---|---|---|
| Series | A metric name and a set of labels, such as route and status class | Its identity; every distinct set of labels is a new series with its own memory |
| Sample | A series, a timestamp and a number | What arrives 6.7 million times a second |
| Block | Two hours of samples for many series, compressed, with a label index | Written once to S3 and never changed; merged and rolled up later |
| Rule and alert | A query, a threshold, a waiting time; the alert’s state: pending or firing | Rules run every 30 seconds; an alert’s state carries across runs |
| Silence | Label matchers, who set it, why, and until when | Mutes pages without deleting the alert or the data |
The one distinction that matters: a series’ identity is its full set of labels. The same name with route="/pay" and with route="/cart" is two series. That is what makes labels useful for slicing a chart, and it is what makes one bad label so expensive.
API
GET /metrics (we scrape the service)
POST /api/v1/push (collector → us)
GET /api/v1/query_range?q=&start=&end=&step=
PUT /rules/{team} POST /silencesSay it, don’t write it: Services only expose a page of numbers. The team sending samples comes from the credentials, never from a label.
Services expose one endpoint, and the system offers four.
| Call | Returns | Why it looks like this |
|---|---|---|
GET /metrics on each service | Plain text: one line per series, name, labels and current value | Any language can print it; the collector does the rest |
POST /api/v1/push | A batch of samples for many series, compressed | How collectors hand samples to the distributors; the team comes from the credentials |
GET /api/v1/query_range?q=…&start=…&end=…&step=60s | One list of timestamped values for each series the query returns | What dashboards and rules call; the query language is PromQL |
PUT /rules/{team}, POST /silences | The team’s rules, or a silence with an end time | Rules are versioned with the team; a silence always expires |
Two choices here matter later. The step in a range query is how far apart the returned points are. A 90-day chart at a 60-second step is 129,600 points per series, far more than a screen can show. So the query service widens the step for long ranges. Prometheus refuses a range query of more than 11,000 points per series. And the push call takes the team from the credentials, never from a label in the batch. A label is something a sender writes, so it cannot decide whose limits apply.
Step 1: collect every series and keep it
Start with the numbers. Every service runs a small library that keeps counters and gauges in memory and prints them on a /metrics page. A collector, running Prometheus, reads that page every 15 seconds. It learns which pages exist from service discovery: the cluster’s list of running pods, or a registry of servers. Fifty thousand targets are too many for one collector, so there are 50 collector groups, each taking 1,000 targets.
The collectors forward every sample to distributors, which are stateless servers. A distributor checks the batch against the team’s sample rate, then hashes each series’ name and labels to choose three ingesters. It returns success once two of the three have the sample.
An ingester refuses a new series past the team’s series limits. Otherwise it appends each sample to its series’ chunk in memory and to a write-ahead log on its disk, so a restart can replay what memory lost. Every two hours it writes its chunks out as an immutable block to S3 and frees the memory.
The interactive version of this example is available when JavaScript loads.
Nothing reads the data yet. The next step makes it visible.
Step 2: chart any series over any range
Ines opens a Grafana dashboard showing checkout’s error ratio for the last hour. Grafana sends a PromQL query to the queriers. A querier finds which series match and asks every ingester for the recent samples it still holds, the last 13 hours by Mimir’s default. It reads older samples from the blocks in S3, through store gateways that cache each block’s index. It merges the three copies of each series, runs the arithmetic, and returns one line per series.
The queriers are stateless, so a slow day is met by adding more of them. Recent data comes from memory, which is why the last hour answers in well under a second.
The interactive version of this example is available when JavaScript loads.
PromQL is the query language Prometheus defined, and many metrics systems, Mimir and Thanos among them, accept it. A query such as sum(rate(checkout_requests_total[5m])) means: for each checkout request series, the average increase per second over the last five minutes, added together. That is checkout’s requests per second across the fleet.
Step 3: turn a rule into a page
Every 30 seconds, a rule evaluator runs each team’s rules through the queriers. A rule says “checkout’s error ratio is above 5%” and “for 2 minutes”. The first time the query returns a result, the alert is pending. If it is still returned after two minutes, the alert is firing, and the evaluator sends it to an alert manager.
The alert manager decides who hears about it. It groups alerts that share a service into one page, routes each group to the owning team’s pager, and holds back anything matching a silence. It pages Ines once, not once per pod.
The interactive version of this example is available when JavaScript loads.
With a steady fleet this is already a working system. The deep dives take it through six moments: a server that dies unnoticed, 6.7 million samples a second, a lost machine, a label that multiplies, a 90-day question, and a page that says resolved while nobody can see.
A server dies at 03:11. Why does nothing page?
At 03:11:53 on a Tuesday, the machine under payment worker 4 loses power. Six workers process card payments. Five keep going, and customers in worker 4’s share of the queue now wait for retries. Ines is asleep. The question is whether anything wakes her.
The first design many people draw has each service push its numbers. Every 15 seconds, each worker sends its counters to an endpoint, and the system stores whatever arrives. It is simple, and it works across any network, because the worker opens the connection.
Walk the night through it. At 03:11:45 all six workers send. At 03:12:00 five send. The system stores five batches and has no reason to think anything is missing. The chart of payments per second dips by about a sixth, which at 03:12 looks like a quiet minute. An alert for “worker 4 sent nothing” would have to know that worker 4 is supposed to exist. Nothing in a push design knows that. A dead worker and a worker with nothing to report look exactly the same: silence.
The fix is to give the system a list of what should be there, and let it go and ask. The collector gets its targets from service discovery, which is the cluster’s own record of running pods and servers. Every 15 seconds it requests each target’s /metrics page. Whatever happens, it writes a sample of its own: up is 1 when the scrape succeeded and 0 when it failed.
Replay the night. At 03:12:00 the collector requests worker 4’s page. A machine with no power sends no answer at all, so after the 10-second scrape timeout the collector writes up{instance="worker-4"} 0 for 03:12:00. A rule says up == 0 for 1 minute, and like every rule it runs every 30 seconds. At 03:12:30 the rule sees the 0, and the alert is pending. At 03:13:30 it is still 0, so the alert fires, and Ines’s phone rings. A missing sample is only visible to something that expected it. The target list is what expects it.
Pulling creates the next problem, which is scale. Fifty thousand targets are 100 million series, far more than one collector’s memory can hold while it forwards them. So the targets are divided by hashing each address into one of 50 groups, and each collector group takes about 1,000 targets. That is 1,000 × 2,000 = 2 million series and about 133,000 samples a second per group. Prometheus does this split with a relabeling rule, a rule that rewrites a target’s labels before the scrape, called hashmod.
Then a collector dies. Its 1,000 targets are no longer scraped. Worse, their up samples stop too, because the collector was the thing writing them. An up == 0 rule sees nothing to compare. A separate collector scrapes the collectors themselves, so a dead collector shows up as its own up 0. And each group runs as a pair: two collectors scrape the same 1,000 targets. Now every sample arrives twice. The distributors, which receive every sample before storage, keep one copy from each pair. Each collector labels its samples with its pair and its own name. The distributors accept samples from one of the two, and switch to the other when the first goes quiet for about 30 seconds. Mimir calls this the high-availability (HA) tracker: “the distributor deduplicates incoming series from Prometheus HA pairs” (Grafana Mimir). Targets can also vanish from the list, for example when the cluster deletes a dead pod. Its up series is then marked stale and disappears, and the up == 0 alert resolves. So a second rule counts what should be there: count(up{job="payments"} == 1) < 6 fires when fewer than six workers are both listed and answering. If the whole job disappears, absent(up{job="payments"}) fires when no up series exists at all.
Push still has a place. A batch job that runs for five seconds may finish before any scrape reaches it, so it pushes its final numbers to a gateway that the collector scrapes. A phone app or a customer’s laptop cannot be reached from outside, so it pushes. Many fleets now push through OpenTelemetry collectors. A push design that wants to notice a dead sender has to rebuild the same thing: a list of who is expected, so that silence can be told apart from quiet.
One more failure sits between the collectors and the distributors. If the distributors are unreachable, a collector keeps its unsent samples in a log on its own disk and sends them when the distributors return. So samples arrive late rather than never. Ingesters accept older samples only within a configured window. An outage longer than that leaves a gap, and the gap shows on every chart.
The experiment plays three minutes around 03:12. The tabs are workers pushing, and a collector pulling from a target list.
The interactive version of this example is available when JavaScript loads.
The gap: A dead source sends nothing, and nothing looks exactly like a quiet night.
Option 1: Every service pushes
Each service sends its numbers every 15 seconds; the system stores what arrives.
Works when: Short batch jobs and devices nobody can reach from outside.
Breaks when: A dead sender is silence, and no rule knows it was expected.
Option 2: Collectors pull from a target list (start here)
Collectors scrape every target from service discovery and record up = 1 or 0.
Works when: Always, for a fleet the collectors can reach.
Watch for: A dead collector takes its targets’ up with it; run pairs, keep one copy, and scrape the collectors too.
Option 3: Push, with a register of expected senders
Senders push; a register of who should be sending marks the silent ones missing.
Works when: Networks where collectors cannot reach the services.
Watch for: The register is a second list to keep right, which pull gets free from service discovery.
In the interview: Open with option 2, and give its reason in one sentence: only something that expected a sample can notice it is missing. Offer option 3 if the interviewer asks about machines you cannot reach. Mention collector pairs and deduplication when they ask what happens if a collector dies.
Say this: Collectors pull each target’s /metrics page every 15 seconds from service discovery. When a scrape fails, they write up = 0, so a dead server pages about a minute after it dies. Targets are split over collector groups by hashing. Each group is a pair, and the distributors keep one replica’s samples. Short jobs and unreachable devices push, but they still need a list of expected senders, or silence looks like health.
6.7 million samples a second. Why not put them in a database table?
The team’s first design stores samples in PostgreSQL. One table, samples(series_id, ts, value), with an index on series and time. Every sample is one row. It is the obvious design, and walking it through shows what a time series store has to be.
Count the bytes. A PostgreSQL row carries a header of 24 bytes and a 4-byte pointer to it in its page. The three columns take 8 bytes each, 24 in all. The index entry for series and time takes about 28 bytes more. That is 24 + 4 + 24 + 28 = 80 bytes for a timestamp and a number. A day is 6,666,667 × 86,400 = 576 billion samples, so 576 billion × 80 bytes is about 46 TB a day, before a single replica.
Then count the work. Each of 6.7 million inserts a second also updates the index. And the reads are wrong-shaped. Ines asks for one series over one hour, 240 samples. Those 240 rows were written one every 15 seconds, between millions of other series’ rows, so they are scattered across the table.
Look at what the data is actually like. Each value is a 64-bit floating-point number, so a sample is 8 bytes of time and 8 bytes of value, 16 in all. Samples of one series arrive in time order. They arrive every 15 seconds, almost exactly. And a series’ value usually changes very little from one sample to the next, or not at all. A good store takes advantage of all three.
So each series gets its own chunk in memory, and samples are appended to it in order. Facebook built the compression for such chunks in a system called Gorilla. Take the timestamps first. Instead of storing each time, store the gap since the previous sample, and then the change in that gap. The gaps are 15, 15, 15, so the change is 0, and a 0 costs one bit. When one scrape runs a second late, the gaps are 16, then 14, then 15 again. The changes are +1, −2 and +1. A small change costs a 2-bit marker plus 7 bits for the change, so each costs 9 bits. Gorilla reports that “about 96% of all time stamps can be compressed to a single bit.” Prometheus stores milliseconds, so its ranges are wider and a late scrape costs 16 bits there; the idea is the same.
Now the values. Compare each value with the previous one bit by bit, using exclusive or, which marks the bits that differ. If nothing differs, store a single 0 bit, which Gorilla reports for “roughly 51% of all values”. A counter that moved from 1,204,311 to 1,204,612 keeps its sign, its exponent and its high digits, so only a short run of bits in the middle differs. Store where that run starts, how long it is, and the run itself. Put together, Gorilla compressed samples “from 16 bytes to an average of 1.37 bytes, a 12x reduction in size.”
The experiment compresses eight samples of three kinds of series with the Gorilla encoding. The tabs are a request counter, a queue that is mostly empty, and a CPU gauge full of noise.
The interactive version of this example is available when JavaScript loads.
The noisy gauge is the honest case: when almost every bit changes, the value barely compresses. The counter costs about 3 bytes. The fleet average is lower because so many values do not change at all: Gorilla found about half of all values identical to the one before. At 1.37 bytes, a day of samples is 576 billion × 1.37 bytes, about 789 GB, against 9.2 TB uncompressed and 46 TB as rows.
The fix creates its own problems. The first is that memory is lost on a restart. So before an ingester acknowledges a sample, it appends it to a write-ahead log on local disk. A restart replays the log. The Prometheus documentation puts it plainly: the current block “is kept in memory and is not fully persisted. It is secured against crashes by a write-ahead log (WAL)” (Prometheus). The log is flushed to disk in batches, so a machine that loses power can lose its last few seconds, while a process restart loses nothing. The copies in the next deep dive cover the machine.
The second is that memory cannot grow forever. So every two hours, the ingester cuts its chunks into an immutable block: the chunks, plus an index. The index lists, for each label value such as status_class="5xx", the IDs of the series that carry it. A query for checkout_requests_total{status_class="5xx"} takes the list for the name and the list for the label and keeps the IDs that appear in both. The block goes to S3 and leaves memory. Twelve blocks a day would mean twelve indexes to open for one day’s chart, so a compactor later merges small blocks into larger ones.
A wide-column store such as Cassandra is the other design teams reach for. It keeps one row per series per hour, with one cell per sample, so one series’ hour is read in one place. Each cell still stores a full timestamp and value with its own overhead, though, and finding series by label needs an index the store does not have.
Now look at what memory really holds. Two hours at one sample every 15 seconds is 480 samples. At 1.37 bytes each, that is about 658 bytes. Mimir’s capacity guide, from the requirements, budgets about 8,333 bytes for each series in memory. Under a tenth of a series’ memory is its samples. The rest is its labels, its entries in the index and the bookkeeping around its chunks. A series costs memory mainly because it exists. That is why the next two deep dives are about how many series there are, and where they live.
The gap: Samples arrive at 6.7 million a second, and each must be cheap to write and cheap to read back by series and time.
Option 1: A row per sample in a SQL table
One row per sample, indexed by series and time.
Works when: Thousands of series, such as one team’s business metrics.
Breaks when: About 80 bytes a sample, 46 TB a day, and one series’ hour scattered across the table.
Option 2: A wide row per series per hour
A wide-column store keeps one row per series per hour, one cell per sample.
Works when: A team that already runs such a store and has few series.
Breaks when: Each cell still stores a full timestamp and value, and finding series by label needs a separate index.
Option 3: Compressed chunks per series, a WAL, and two-hour blocks (start here)
Append to each series’ chunk in memory with delta-of-delta times and XOR values, log to disk, and write indexed blocks to S3 every two hours.
Works when: Always, for metrics.
Watch for: The last two hours live in one machine’s memory until the next deep dive copies them.
In the interview: Open with option 3, and earn it with the row arithmetic: 80 bytes against 1.37. Then say why the data compresses: regular times and values that barely change. Mention the WAL before the interviewer asks what a restart loses.
Say this: Samples arrive in time order, every 15 seconds, with values that barely change, so each series gets a chunk in memory. Times are stored as the change in the gap, usually one bit. Values are stored as the bits that differ from the previous value. Gorilla brought a sample from 16 bytes to 1.37 this way. A write-ahead log covers a restart. Every two hours the chunks become an immutable block in S3 with a label index. Most of a series’ memory is its labels and index, not its samples, so the series count is what I watch.
One machine cannot hold 100 million series. How do you split them?
At about 8,333 bytes each, 100 million series need about 833 GB of memory. The ingesters are machines with 32 GB, of which about 25 GB can go to series. Each is planned to hold 3 million series, about 25 GB, and keeps the other 7 GB as room for spikes. Even one copy of everything needs 34 machines. The fleet will end up with 100, for a reason this section reaches at its end. The first question is how a series picks its machine.
The first idea keeps each metric name on one ingester. A query for one metric would then touch one machine, which sounds efficient.
Walk it through. The largest name in the fleet is the latency histogram that every service exposes, http_request_duration_seconds_bucket. Say it holds 12% of all series. That is 12 million series on one machine, which at 8,333 bytes each is 100 GB, on a machine with 32. It also receives 12% of all samples, 800,000 a second. An even share of 6.7 million over the 100 machines would be about 67,000. The machine falls over. When it does, the whole metric goes with it: every service’s latency, for the last two hours, at once.
The fix is to hash each series’ full identity: the team, the name and the labels, sorted. Two series of one metric then land on different machines, and every metric spreads across all of them. The ring that assigns hashes to ingesters works like consistent hashing, so adding an ingester moves only a small share of series. With 100 ingesters, each holds about 1 million series of one copy and 67,000 samples a second, whatever is popular.
This creates the next problem at once. A query for one metric now touches every ingester, because that metric’s series are everywhere. That is acceptable. Each ingester answers from memory, all of them answer in parallel, and the querier merges the answers. The cost is that the slowest ingester sets the query’s time, so an ingester that is struggling slows every chart.
Then a machine is lost for good at 11:40, disk and all. Its write-ahead log goes with it. About 1 million series lose their last two hours of samples, because that memory was the only copy.
So every series lives on three ingesters. The distributor sends each sample to all three and reports success once two have it. Mimir’s documentation describes exactly this: “with an RF of three, a write request succeeds if each series is successfully written to at least two ingesters” (Grafana Mimir). Replay 11:40: every sample the lost machine held was confirmed on at least one other ingester, normally two. Queries read all the copies and merge identical samples. The three copies go in three different zones, so losing a whole zone still leaves two.
That is where the number of machines comes from. 100 million series × 3 copies is 300 million series in memory. At 3 million per ingester, that is 100 ingesters, with about 2.5 TB of memory between them.
The experiment places series on the ingesters three ways, then loses one machine. The tabs are by metric name, by series with one copy, and by series with three copies.
The interactive version of this example is available when JavaScript loads.
Three copies create one more problem. All three ingesters write the same two hours as a block, so S3 receives every block three times. A compactor merges the copies. It reads the blocks that cover the same two hours, one from every ingester, drops the samples that appear more than once, and writes one block. It also merges small blocks into bigger ones, as the storage deep dive needed.
Newer designs put a log such as Kafka between the distributors and the ingesters. The distributors write each sample to a partition, and the write is done once Kafka has it. Ingesters read their partitions and can replay them after a restart. Mimir now prefers this: “Starting with Grafana Mimir 3.0, ingest storage architecture is stable and the preferred architecture for running Grafana Mimir” (Grafana Mimir). The gain is separating reads from writes. A flood of heavy queries slows the ingesters, and with a log in front, that no longer slows ingestion. The cost is another cluster to run. The three-copy ring is the older, simpler shape, and the one an interviewer usually expects first.
The interactive version of this example is available when JavaScript loads.
The gap: No machine can hold every series, and whichever machine holds a series’ last two hours can be lost.
Option 1: By metric name
All series of one metric on one ingester.
Works when: A few small metrics of similar size.
Breaks when: The biggest metric, 12% of series, needs 100 GB on a 32 GB machine, and its loss takes the whole metric.
Option 2: By series hash, one copy
Hash name and labels; each series on one ingester.
Works when: Data you can afford to lose for two hours.
Breaks when: A lost machine takes about 1 million series’ last two hours with it.
Option 3: By series hash, three copies, two to acknowledge (start here)
Each series on three ingesters in three zones; a write succeeds on two.
Works when: Always, for a fleet this size.
Watch for: Three times the memory, 2.5 TB; a sample confirmed on two survives one loss, not two.
Option 4: A log in front of the ingesters
Distributors write samples to Kafka partitions; ingesters read and replay them.
Works when: Heavy queries must never slow ingestion, or several systems read the same samples.
Watch for: Another cluster to run and size; the ring is simpler to explain first.
In the interview: Open with option 3, and derive the 100 ingesters out loud: 100 million series, three copies, 3 million per machine. Show option 1 failing on the biggest metric. Mention the query fan-out before the interviewer does, and say why it is acceptable.
Say this: Each series is hashed by its name and labels onto a ring of ingesters, so every metric spreads evenly. Each series lives on three ingesters in three zones. A write succeeds once two have it, so losing one machine loses no confirmed sample. That is 300 million series in memory, about 100 ingesters and 2.5 TB. A query fans out to every ingester and merges, and a compactor merges the three copies of each block in S3.
A developer adds one label. Why does every team lose its metrics?
At 16:00 on a Friday, Dario ships a small change to checkout. Support keeps asking how slow checkout was for one particular customer, so he adds a customer_id label to checkout’s latency histogram, checkout_request_seconds. The change passes review. It is one line. The number of distinct series a metric has is called its cardinality, and this line is about to change it.
Count the series before the change. Checkout runs 40 pods, serves 25 routes, and reports 4 status classes, so there are 40 × 25 × 4 = 4,000 combinations of labels. The histogram keeps 12 bucket counters for each, plus a sum and a count, 14 series in all. That is 4,000 × 14 = 56,000 series, which the system has carried for years.
Now add the customer. Checkout serves 500,000 different customers an hour, and each customer’s requests land on about three combinations of pod, route and status. That is 1,500,000 new combinations an hour, and 14 series each: 21 million new series an hour. The whole fleet had 100 million.
Follow them into memory. Each new series is kept on three ingesters, so 63 million series in memory an hour, spread over 100 ingesters: 630,000 each. At 8,333 bytes, that is 5.25 GB of new memory an hour on every ingester. Each has 32 GB and was planned to use about 25, so the 7 GB of room lasts 7 ÷ 5.25 hours, 80 minutes. Prometheus’s newer native histograms keep all buckets in one series, which would cut the 14 series per combination to one. The arithmetic changes; the rule does not. At 17:20, every ingester runs out of memory.
The failure is fleet-wide. The hashing from the last deep dive spreads the new series evenly, exactly as it was built to. So all hundred machines fill at the same rate, and they fall over within minutes of each other. Every team loses its metrics and its alerts, on a Friday evening, because of one team’s label.
The samples grow too. A client library keeps every label value it has seen until the process restarts, and prints all of them on every scrape. After one hour, the 21 million new series send a sample every 15 seconds: 21,000,000 ÷ 15 is 1.4 million more samples a second, a fifth more than the whole fleet. Memory runs out first, though, because every series costs its full 8,333 bytes from its first sample.
The first idea is bigger machines. But the label has no ceiling: tomorrow brings new customers, and next month more. The second idea is to cut checkout off at the door. That protects everyone else, and it deletes checkout’s error rate at the moment someone is trying to find out what checkout broke.
So the ingesters enforce limits before they create a new series. Each ingester holds its share of every team’s limit, so across the fleet a team is refused past its total. The first is a limit per team. Checkout’s team may hold 2 million series, and it held 1.5 million. The explosion fills the other 500,000 in 500,000 ÷ 21,000,000 of an hour, about 86 seconds. From 16:01:26 the ingesters refuse every new series from the team. Existing series keep flowing. The platform is safe.
Replay the rest of the evening. At 16:30 the evening rush begins and autoscaling adds 10 checkout pods. Their error counters are new series, so the ingesters refuse them too. Checkout’s error ratio is now computed without the 10 newest pods, and nothing on the chart says so. A limit on the whole team punishes the team’s healthy metrics for one bad one.
So add a limit per metric name, inside the team’s. A histogram is three metric names: checkout_request_seconds_bucket with the 12 buckets, and _sum and _count. Each name may hold 200,000 series. The bucket name started at 4,000 × 12 = 48,000, and gains 18 million series an hour. Its other 152,000 fill in 152,000 ÷ 18,000,000 of an hour, about 30 seconds. From 16:00:30, the ingesters refuse its new series. The _sum and _count names gain only 1.5 million an hour each, so they reach 200,000 at 16:07:50. Only those three names are refused. They tell the collector why, and they count every refusal by team, metric and reason. An alert tells the checkout team which metric is being cut. At 16:30 the 10 new pods’ error counters arrive as usual. The latency histogram is incomplete, and the system says so.
The experiment plays the ninety minutes after the deploy. The tabs are no limit, a limit per team, and a limit per metric.
The interactive version of this example is available when JavaScript loads.
Each ingester also has a hard ceiling of its own, max_series, as the last line of defence when the teams’ limits add up to more than the fleet can hold.
The limit buys time. The label still has to go. The checkout pods pay too: the client library holds every customer’s counters in the pod’s own memory. On the collector, Prometheus’s sample_limit is a blunter guard. It fails the whole scrape of a pod that prints too many samples, and every series from that pod goes dark with it, error counters included. Some teams set it anyway, because a dark pod pages through up == 0, while a flood fills memory in silence. At the collectors, a relabeling rule can drop every sample that carries customer_id while the fix ships. Dropping only the label would not work: many series would collapse into one name and label set, and their samples would clash. The real fix is deleting the label from the code.
What Dario wanted, one customer’s latency, belongs in logs or traces, which store one record per request and are built for high-cardinality lookups. A histogram can still point at them. An exemplar attaches a trace ID to a bucket sample, so a click on a slow bucket opens one real slow request, without a series per customer.
Churn, series that appear and later go quiet, needs the same care. A pod’s name is a label, so every deploy creates new series for every pod, and the old ones stay in memory until their block is written out. A team that deploys often briefly holds its series count twice, so its limit is sized with deploys in mind.
Even hashing is why one team’s mistake reached every machine. Shuffle sharding, in the section on many teams, places each team on a small subset of ingesters, so a mistake like this one fills a few machines instead of all of them.
The gap: A label with unbounded values multiplies series, and each series costs memory on three ingesters whether or not it gets a second sample.
Option 1: No limits, bigger machines
Accept every series and add memory when needed.
Works when: A small fleet where every label is reviewed by hand.
Breaks when: The label has no ceiling, and even hashing fills every ingester at once: all 100 fail at 17:20.
Option 2: A limit per team
The ingesters refuse new series once a team holds 2 million.
Works when: As the outer fence around each team.
Breaks when: The team’s healthy new series are refused too: 10 new pods’ error counts, silently.
Option 3: A limit per metric, inside the team’s (start here)
Refuse new series for one metric name past 200,000, count refusals, and alert the owning team.
Works when: Always.
Watch for: The capped metric is incomplete until the label is removed, and the alert has to say which metric.
In the interview: Open with the arithmetic: 21 million new series an hour, 5.25 GB an hour per ingester, 80 minutes. Then point out that even hashing is why every ingester fails together. Offer option 3 with option 2 around it, and finish with where the per-customer data belongs: logs, traces and exemplars.
Say this: Every distinct set of labels is a series, and memory is paid per series on three ingesters. A customer ID label turns 56,000 series into 21 million new ones an hour. Even hashing makes every ingester fail at the same time. The ingesters enforce a series limit per metric name inside a limit per team, refuse new series past it, and tell the owning team which metric was cut. Per-customer questions go to logs and traces, and exemplars link a bucket to a trace.
Show the p99 for the last 90 days. What does the query read, and is the answer true?
At the quarterly capacity review, someone asks for checkout’s p99 latency, hour by hour, for the last 90 days. The p99 is the time within which 99% of requests finished. Only the slowest 1% took longer, so it marks where the slow requests customers felt begin. The percentiles guide explains why teams track it instead of the average.
The histogram answers the question from its buckets. Each of the 4,000 label combinations has 12 bucket series, 48,000 in all. If raw samples were kept that long, 90 days of samples every 15 seconds would be 90 × 5,760 = 518,400 samples per series. Across 48,000 series that is about 24.9 billion samples, about 34 GB to fetch from S3 and decompress, for one chart. The chart would take minutes, and a dashboard with ten charts would take the afternoon.
The first half of the fix removes series the question does not need. The chart adds up every pod, route and status. So a recording rule does that once an hour: it adds up each bucket’s increase over the hour and stores the result, one series per bucket for the whole fleet, 12 series. A recording rule only covers the time since it was created, so the rules behind the charts people rely on are set up on the first day. Ninety days of hourly values for 12 series is 90 × 24 × 12 = 25,920 values. The chart reads those in well under the 5 seconds the requirement allows.
Charts nobody planned for still need old data to be smaller. A compactor that downsamples, as Thanos’s does, rewrites old blocks at 5-minute and 1-hour resolution. For each series and window it keeps the count, the sum, the minimum, the maximum and the counter’s increase (Thanos). Mimir does not downsample, and leans on recording rules and caching instead.
The tiers follow the requirements. Every sample is kept for 15 days, 5-minute blocks for 90 days, and hourly blocks and recording rules for 13 months.
A rollup keeps only what it was built to keep, and the raw samples are deleted after 15 days. What should it keep? Walk through one hour that matters.
That quarter, for one hour, one of checkout’s 40 pods sat on a failing machine. Every request it served took between 2.5 and 5 seconds. The other 39 pods had a p99 of 250 ms. Traffic was spread evenly, 100,000 requests per pod that hour, so the slow pod served 1 in 40 requests, 2.5% of them.
The first design keeps the average latency. The healthy pods averaged 80 ms and the failing one 3.75 s, so the hour’s average is (39 × 80 ms + 3.75 s) ÷ 40, about 172 ms. It looks healthy. An average cannot show a tail, and this hour was all tail.
The second design keeps each pod’s p99 for the hour, and the chart averages them. Thirty-nine pods say 250 ms. One says about 5.0 s. All its requests are in the 2.5 to 5 second bucket, and a p99 read from buckets assumes they are spread evenly inside it, so its 99th percentile lands at 2.5 + 0.99 × 2.5, which is 4.975 s. The average is (39 × 0.25 + 4.975) ÷ 40, about 368 ms. That is wrong too. A pod’s p99 describes that pod’s requests only. Percentiles of two groups cannot be combined into the percentile of both.
The third design keeps the bucket counts. A bucket is a counter of requests that finished within some time, such as 250 ms or 2.5 s. Counts can be added. Add the 40 pods’ buckets, then find the 99th percentile of the combined counts. 2.5% of requests sat in the bucket between 2.5 and 5 seconds, more than the 1% a p99 looks past, so the fleet’s p99 is in that bucket. The fleet served 4,000,000 requests, so the p99 is request number 3,960,000 in order of time taken. 3,900,000 finished within 2.5 s, so it is 60,000 of the 100,000 into that bucket. Assuming requests are spread evenly inside the bucket, that is 2.5 + 0.6 × 2.5, which gives about 4.0 s. What the rollup keeps decides which questions can ever be asked again. The Prometheus documentation says the same: “aggregating the precomputed quantiles from a summary rarely makes sense”, while with histograms “the aggregation is perfectly possible” (Prometheus).
The experiment reads that hour from three kinds of rollup. The tabs are keeping the average, keeping each pod’s p99, and keeping the bucket counts.
The interactive version of this example is available when JavaScript loads.
The same rule covers every kind of series. A rollup keeps quantities that can be combined: counts and sums add up, and the minimum and maximum take the smaller or the larger. The average is then sum ÷ count, and the peak is still there. Bucket bounds set the precision. 4.0 s is an estimate somewhere between 2.5 and 5 seconds, and a finer bucket would narrow it.
Counters need one more piece of care. A counter only grows, until its process restarts and it starts again from 0. A pod’s request counter reads 5,000, then 12 after a restart. Taking last minus first gives −4,988 requests. The rollup must add up the increases and treat a drop as a restart. PromQL’s rate() does the same: “Breaks in monotonicity (such as counter resets due to target restarts) are automatically adjusted for” (Prometheus).
Long queries also get cheaper when a query service in front of the queriers splits them by day and caches the finished days. Yesterday will not change, so a 90-day chart opened twice reads 89 days from cache.
The gap: A 90-day chart cannot read billions of raw samples, and a rollup keeps only the answers it was built to give.
Option 1: Read the raw samples
Every chart reads every 15-second sample in the range.
Works when: The last few hours, and the last 15 days at most.
Breaks when: Ninety days is about 24.9 billion samples, 34 GB, for one chart.
Option 2: Roll up averages and percentiles
Keep each series’ hourly average and each pod’s hourly p99.
Works when: Nowhere a tail matters.
Breaks when: The hour with one failing pod reads 172 ms or 368 ms, when the fleet’s p99 was about 4.0 s.
Option 3: Roll up counts: buckets, sums, counts, minimum and maximum (start here)
Recording rules sum what charts combine; rollups keep quantities that combine, with reset-aware counter increases.
Works when: Always.
Watch for: The bucket bounds set the precision, and anything not kept is gone after 15 days.
In the interview: Open with option 3 and the read arithmetic: 24.9 billion samples against 25,920 values. Then walk the failing pod to show why a percentile cannot be rolled up. If the interviewer asks about averages, say they come from sum and count.
Say this: Long ranges read rollups, not raw samples. Hourly recording rules sum the series a chart combines, and a downsampling compactor keeps 5-minute and hourly blocks for everything else. A rollup keeps only quantities that combine: bucket counts, sums, counts, minimum and maximum, and counter increases that treat a drop as a restart. Averages hide tails. Percentiles cannot be combined, so the fleet’s p99 is computed from summed buckets. Raw samples go after 15 days, so what the rollup keeps is decided before they do.
Checkout is failing, and the page says resolved. What happened?
By 09:00, checkout’s error ratio over the last five minutes has climbed to 8%. The rule says above 5% for 2 minutes, and it runs every 30 seconds. At 09:00:00 the alert is pending. At 09:02:00 it fires, and Ines is paged. She opens her laptop. At 09:03:15, the network between checkout’s cluster and its collectors fails. Checkout is still failing. What does the pager say next?
Walk the rule through it. It computes rate() over a five-minute window, and the window still holds samples from before 09:03:15. The error and request counters stopped at the same moment, so their ratio stays at 8%, computed from samples that are no longer arriving. The chart looks the same as a minute ago. Nothing on the page says it has not been measured since 09:03:00.
Then the window runs out. By 09:08:00 fewer than two samples remain in it, rate() has nothing to compute, and the query returns no result at all. To a rule engine, no result means the condition is not met. The alert becomes inactive. At its next update for the group, the alert manager sends “RESOLVED: checkout errors”, as most pagers are set to receive. Ines had been about to call the checkout team. The page says it recovered. Nobody has seen checkout for five minutes.
This timing belongs to rate(). A rule on a gauge, read without a window, goes empty at the first failed scrape.
A rule is a query. An empty answer means nothing matched, and the rule reads that as healthy.
The first fix holds the alert. Prometheus has keep_firing_for, which “tells Prometheus to keep this alert firing for the specified duration after the firing condition was last met” (Prometheus). With 10 minutes, the alert stays up after 09:08. The rule last found a breach at 09:07:30. Prometheus starts the ten minutes at the first evaluation that finds nothing, 09:08:00, so at 09:18:00 it resolves. The page still says recovered, still while blind. Holding the alert only delays the false recovery.
The real fix keeps the hold and adds a second rule about the collection itself. up{job="checkout"} == 0 for 1 minute. The first failed scrape writes up 0 at 09:03:15. At 09:03:30 the rule is pending, and at 09:04:30 it pages: checkout cannot be scraped. Now Ines knows two true things. Errors were high, and the system has gone blind to checkout. When the hold ends at 09:18, the blind alert is still firing. Grouped by service, the page shows the two together, never a lone recovery. For the case where checkout’s targets vanish from service discovery, so that no up series exists at all, a third rule uses absent(up{job="checkout"}). Every alert about a service needs a partner alert about whether the service can be seen.
The experiment plays 09:00 to 09:20 three ways. The tabs are the error rule only, the error rule held for 10 minutes, and the error rule plus a rule on failed scrapes.
The interactive version of this example is available when JavaScript loads.
Two smaller rules keep pages honest in both directions. The for clause means one bad evaluation never pages anyone. And rules should watch what customers feel, errors and latency, more than causes such as CPU. Google’s SRE book advises that “it’s better to spend much more effort on catching symptoms than causes” (Google SRE). The SLO guide shows how an error budget turns that into a rule.
Then comes the hardest case. At 02:00 the monitoring cluster itself loses its network. The rule evaluator cannot reach its data or the alert manager, so no rule fires, including the one about checkout, including the one about the monitoring cluster. The pager is silent, and silence is exactly what a healthy night looks like.
The fix is a rule that always fires, called a watchdog. Every minute, it travels the whole path, from the rule evaluator to the alert manager. The alert manager routes it with a one-minute repeat, out to a dead man’s switch: a small service run on another provider. That service pages when the heartbeat stops for 5 minutes. The Prometheus Operator’s runbook describes it: “This is an alert meant to ensure that the entire alerting pipeline is functional. This alert is always firing” (Prometheus Operator). It must run somewhere else, because a switch on the same network would go silent with everything it watches.
The watchdog proves the path from the evaluator outward, and its rule reads no data. A rule whose query fails, because the queriers are overloaded, stops updating its alerts. The alert manager treats an alert it stops hearing about as resolved after a few minutes. So the evaluator watches itself too: one rule pages when rule evaluations fail, and another when samples reach storage later than usual.
The interactive version of this example is available when JavaScript loads.
The gap: A rule sees only the samples that arrive, and when none arrive it returns nothing, which it reads as healthy.
Option 1: The error rule only
Page on the error ratio above 5% for 2 minutes.
Works when: Only if collection never fails.
Breaks when: When scrapes fail it reports stale numbers, then resolves at 09:08:00, still blind.
Option 2: Hold the alert after the data stops
The same rule with keep_firing_for 10 minutes.
Works when: To stop a brief gap from flapping a real alert.
Breaks when: It resolves at 09:18:00 instead, still blind.
Option 3: Hold the alert, pair it with scrape and absence rules, add a watchdog (start here)
Keep the hold, add up == 0 and absent(up) for each service, and an always-firing heartbeat to a switch elsewhere.
Works when: Always.
Watch for: More rules per service to keep in step; generate them from one template per service.
In the interview: Open with the failure itself: an empty query result reads as healthy. Then pair the rules: errors, failed scrapes, and missing targets. Finish with the watchdog before the interviewer asks who watches the monitor.
Say this: A rule is a query, and when the data stops the query eventually returns nothing, which the rule engine treats as resolved. So each service’s error rule has partners: up == 0 for failed scrapes and absent(up) for targets that disappear, which page as “cannot see checkout”. keep_firing_for alone only delays the false recovery. An always-firing watchdog goes through the whole path to a dead man’s switch on another provider, which pages when it stops.
The interactive version of this example is available when JavaScript loads.
The code has four tabs: the collector’s scrape configuration, the ingestion limits, the alert rules, and the 90-day query.
If they ask: one outage, two thousand pages
A zone fails and 2,000 instance alerts fire at once. The alert manager waits a short time, 30 seconds, to gather alerts that share a service and a name, and sends one page per group. Inhibition suppresses the instance alerts while a “zone down” alert is firing for the same zone. The documentation defines it: “Inhibition is a concept of suppressing notifications for certain alerts if certain other alerts are already firing” (Prometheus). Silences mute planned work with an end time. Two alert managers run as a cluster and share which notifications they have sent, so a page normally goes out once. During a network split between them, both may send it. The rule evaluator sends every alert to both rather than to a load balancer. The pager itself is a notification system, which the notification system breakdown designs.
If they ask: many teams, or many customers
Every limit on this page is per team, called a tenant. The distributor reads the tenant from the credentials, never from a label. It then applies that tenant’s limits on series, samples a second and query cost. A product like Datadog is the same design with customers as tenants. Two more pieces matter there. A customer’s series can be placed on a small, fixed subset of ingesters, so one customer’s overload touches only a few machines; Mimir calls this shuffle sharding. And agents on the customers’ machines push, because nothing outside can reach them, which brings back the expected-sender register from the collection deep dive.
If they ask: logs and traces
Metrics say that something is wrong and how much. Logs say what one request did. Traces show one request’s path across services. Each has its own store, sized for one record per event rather than one series per label set. The metrics system links to them: a dashboard panel opens the logs for the same service and minute, and exemplars attach a trace ID to a histogram bucket. Storing request IDs as labels would turn the metrics store into a very expensive, very slow log store, which is the cardinality deep dive again.
Walk one sample through the final design
At 09:00:14 checkout pod 17 fails a payment and adds one to checkout_requests_total for route="/pay" and status_class="5xx". At 09:00:15 both collectors of its group scrape the pod. The distributors keep the samples from one of the pair, check the checkout team’s sample rate, and hash the series to three ingesters in three zones. Two acknowledge, and the collector moves on.
Each ingester appends the sample to the series’ chunk in memory, in about a byte and a half, and to its write-ahead log. At 09:00:30 the rule evaluator asks the queriers for checkout’s error ratio. The queriers ask every ingester, merge the copies, and return 8%, with this sample part of it. The alert has been pending since 09:00:00, it fires at 09:02:00, and the alert manager pages Ines once. Around 11:00, when the two-hour block closes, the ingesters write it to S3, and the compactor merges the three copies into one. After 15 days the raw block is deleted, and the sample lives on inside the 5-minute and hourly bucket counts.
The interactive version of this example is available when JavaScript loads.
| Requirement | Where it is met | The trade-off |
|---|---|---|
| FR1 collect and keep every series | Collector pairs from service discovery, distributors, three ingesters with a WAL, two-hour blocks in S3 | The last two hours live in memory, 2.5 TB of it |
| FR2 chart any series, any range | Queriers over ingesters and blocks, hourly recording rules, downsampled blocks of counts and sums | Precision beyond the bucket bounds is gone after 15 days |
| FR3 page on a rule | Rule evaluator every 30 s, alert manager grouping, scrape and absence rules, a watchdog | Each service carries several rules, generated from a template |
| One team cannot take down the rest | Series limits per team and per metric name at the ingesters, and a ceiling per ingester | A capped metric is incomplete until its label is fixed |
| Never report a recovery it did not see | up == 0 and absent(up) partners for each rule | A page can say “blind” when collection, not the service, is broken |
How does the answer change for Datadog, Prometheus or a time series database?
| Interview variant | What carries over | What changes |
|---|---|---|
| Design Datadog | The storage, the limits, the rollups and the alerting | Customers’ agents push, so the expected-sender register returns, and tenants need shuffle sharding and billing |
| Design Prometheus | Collection, the chunk format, blocks and rules | One server holds everything; ask whether they want one machine or the distributed version |
| Design a time series database | The storage and sharding deep dives | The interview centres on compression, the label index, out-of-order writes and compaction |
| Design a metrics monitoring and alerting system | Everything on this page | Often the same question under a longer name |
| Design a server health monitoring system | Collection and the scrape rules | Fewer series per machine; missing data and the watchdog become the whole problem |
| Design an alerting system | The rule evaluator and alert manager | Often means delivering the page; see the notification system breakdown |
What should an answer reach at each level?
| Level | What the answer shows |
|---|---|
| Intern or mid-level | Collects metrics with agents or scrapers, stores them in a time series database, charts them, and runs threshold rules that page. |
| Senior | Pulls from a target list and uses up to catch dead servers. Explains why time series compress and what a block and a WAL are. Shards by series with replicas, and downsamples for long ranges. |
| Staff | Works out that memory follows the series count, sets per-metric limits inside per-team ones, and keeps rollups that can be combined. Pairs every alert with scrape and absence rules, and adds a watchdog. |
| Principal | Decides what the rollups keep before raw data is deleted, where per-request detail lives instead, how limits and tenants are enforced for customers, and how the monitor is watched from outside. |
Test yourself with the quiz, then pick another problem from the System Design interview breakdowns.
By GOAT Engineer. Back to all breakdowns. Privacy Policy · Contact.