CodingNodes Space play · ←→ step · R restart

The problem

An observability system answers two different questions at very different times. 'Is it healthy right now?' is a question for the dashboards, answered on demand. 'Something is wrong — wake someone up' is a question for the alerting pipeline, answered continuously in the background. Both questions are answered by the same store of numbers, but they get at it in opposite ways: one pulls a window of history, the other watches the latest point and fires when it crosses a line.

So the design has two halves bolted to one store. The collection half gets numbers into the system — services emit them, an agent or a push path gathers them, and ingestion parses and tags them into a time-series store. The query half reads a window of that store, downsampling it to the right resolution, and renders a chart. And the alerting half sits on the live edge of the store, evaluating rules, collapsing the noise, and routing the signal to a human. We will build the collection, the store, the query, and the alerting, then close the loop with one metric that is emitted, stored, charted, and — when it spikes — paged to an on-call engineer, with the noise deduplicated along the way.

Requirements

Functional — what it must do

  • Collect: services emit metrics continuously, and the system ingests them with their identifying tags into a time-ordered store.
  • Query: a dashboard requests a window of a metric, and the system returns it at the resolution that fits the view, fast.
  • Alert: a rule continuously evaluates the live series, and when it fires, routes a single, deduplicated notification to the right on-call.

Non-functional — how well it must do it

  • Ingestion is a firehose: hundreds of thousands of samples per second at peak, and the system must not drop samples under a burst.
  • A dashboard query over a day of a busy metric answers in a second or two, by reading the downsampled series rather than the raw one.
  • Alerting is low-noise by design: a sustained condition is one page, not one page per evaluation, and a flapping metric does not wake anyone.

Scale — how much it must take

  • On the order of hundreds of thousands of samples per second across thousands of series, with raw retention of days and downsampled retention of months.

Assumptions — the numbers this design is sized for

A rate limit means nothing without a scale. These are the figures every later part relies on: how much traffic arrives, how much work the limiter has to do per second, and how much latency and memory it may spend doing it.

Ingestion
~500K samples/s (peak)
The firehose. The ingestion path must absorb a burst without dropping samples.
Series
~10K
The distinct time series. Each is (metric, tags) and grows unboundedly as tags grow.
Raw retention
days
Full-resolution samples kept for a short window — enough for a detailed recent look.
Downsampled
months
Coarser aggregates kept for a long window — a dashboard over a week reads these, not the raw.
Query latency
< 2 s
A dashboard over a day of a busy metric. Downsampling is what keeps it under this budget.
Alert eval
every few seconds
The rule engine evaluates the live series continuously, not on a schedule.
Noise budget
one page / incident
A sustained condition is one notification. The dedup and grouping are what protect the on-call's sleep.

Takeaways

Part 1

The four signals

Observability is not one thing. It is four signals — metrics, logs, traces, and events — and the system in this chapter is the metrics one. Knowing the difference keeps the design honest.

  1. 1
    Four signals, different shapes

    Metrics are numbers over time — a rate, a count, a gauge. Logs are timestamped text — a line per event. Traces are a request's path across services — the causal chain. Events are discrete facts — 'deploy happened', 'alert fired'. They answer different questions and are stored and queried differently.

  2. 2
    This chapter is the metrics one

    Metrics are the only signal that is a continuous number, and that is exactly what makes it alertable: a threshold can be set on a number, and a rule can fire when it crosses. Logs and traces are how you debug after the fact; metrics are how you notice in the first place. The rest of this chapter is the metrics pipeline and the alerting built on it.

Part 2

Getting the numbers in

Services emit metrics continuously; the collection path gathers them, tags them with their identity, and writes them into the time-series store. The firehose is the design constraint.

  1. 1
    A metric is a number with a tag

    A metric is not just a value — it is a value with an identity. The metric name, plus a set of tags — service, host, region, handler — is what makes it a distinct series. Two services both reporting 'requests' are two series, because their tags differ. The tag is the key that makes the number mean something.

  2. 2
    Pull vs. push

    There are two ways to move a metric from a service to the store. Pull: a central agent visits each service on a schedule and reads its current value. Push: each service sends its value to the ingestion endpoint as it happens. Pull is simpler to operate and self-discovers services; push is lower latency and does not depend on the agent reaching the service. Most systems use pull for gauges and push for counters.

  3. 3
    Ingestion: parse, tag, write

    The ingestion service receives the samples, parses them, fills in the tags, and writes them into the time-series store keyed by (metric, tags) and ordered by time. It is the single write path, and it must be fast enough to absorb the firehose — a burst of samples is buffered and written, not dropped.

Part 3

The time-series store

The store is a time-ordered log per series, kept at two resolutions: raw for the recent window and downsampled for the long window. The resolution is what makes a day-long query fast.

  1. 1
    A series is an ordered log

    Each (metric, tags) is a series, and a series is an append-only sequence of (time, value) pairs. Writing is an append, which is cheap; reading a window is a range scan over the sequence. The store is organized for exactly these two operations and nothing else — that is why it is a time-series database and not a general-purpose one.

  2. 2
    Downsample to keep it fast

    A day of a busy metric is a huge number of raw points. A dashboard does not need all of them — it needs a line that fits the view. The store keeps a downsampled copy: the raw samples are aggregated into a coarser resolution, say one value per minute, and a long-window query reads the coarse series, not the raw one. That is what keeps a day-long query in a couple of seconds.

  3. 3
    Resolution follows the window

    The rule of thumb is that the resolution follows the window: the narrower the window, the finer the resolution. A look at the last five minutes reads the raw series; a look at the last week reads the downsampled one. The query service picks the resolution from the window's span, so the chart is always fast and the detail is always there when you zoom in.

Part 4

The dashboard query

A dashboard sends a window and a metric; the query service resolves the series, picks the resolution for the span, reads the store, and returns points the chart can render. One round trip, a bounded read.

  1. 1
    The query is a window

    A dashboard query is four things: which metric, which tags, which time window, and how many points to return. The query service resolves the (metric, tags) to a series, and the window tells it how much of the series to read. The 'how many points' is what ties the resolution to the chart's width.

  2. 2
    Resolve, read, return

    The service resolves the series, picks the resolution from the window's span, reads that range from the store, and returns the points. The read is bounded by the window and the resolution, so it is a range scan over a known amount of data — not a scan of the whole store. That boundedness is what keeps a dashboard fast.

  3. 3
    The chart is the last hop

    The dashboard renders the points as a line over the window. Because the points came pre-downsampled to the chart's width, the render is cheap — a few hundred points, not a few million. The whole path, from query to pixels, is a bounded read and a cheap draw, which is why a dashboard feels instant even over a busy metric.

Part 5

The alerting pipeline

The rule engine watches the live series and fires when a condition holds. The rest of the pipeline is noise control: dedup collapses the repeats, grouping bundles the related, and the router sends one clean notification to the right human.

  1. 1
    A rule is a condition with a duration

    An alert rule is not 'the value crossed a line' — it is 'the value has stayed above the line for a duration'. The duration is what separates a real incident from a one-sample spike. A rule fires only when the condition has held for its window, which is the first and most important noise filter.

  2. 2
    Dedup: one condition, one page

    A rule that is true will be true on the next evaluation too, and the one after that. Without dedup, every evaluation would page. The dedup step collapses the repeated firings of the same rule into a single active alert, and re-pages only if the alert clears and then fires again. One sustained condition is one page, not one page per evaluation.

  3. 3
    Group, then route by severity

    Related alerts — several services down, one region failing — are grouped into a single incident so the on-call sees one problem, not six. The router then sends it by severity: a page to the on-call for a critical alert, a quieter channel for a warning. And every alert is recorded in an incident log, so the history is a record, not a memory.

Part 6

The alert lifecycle

An alert is not a moment, it is a state machine: firing, acknowledged, resolved. Tracking the state is what stops a resolved alert from re-paging and gives the on-call a clean handoff.

  1. 1
    Fire, ack, resolve

    An alert moves through three states. It fires when the condition holds for its duration. It is acknowledged when someone takes ownership — that stops the re-page and tells the system a human is on it. It is resolved when the condition clears. The state is stored with the alert, so the history is a timeline, not a list.

  2. 2
    The ack stops the re-page

    The moment an alert is acknowledged, the router stops re-paging for it, even though the condition may still be true. That is the point of the ack: it separates 'this needs a human' from 'this is being handled'. Without it, a real incident would page the on-call every few minutes until it was fixed.

  3. 3
    The noise budget is the design goal

    The whole pipeline — the duration, the dedup, the grouping, the severity routing, the ack — is in service of one goal: that the on-call is woken by a real problem, and only a real one. An alerting system that is right all the time but pages for every blip is a system the on-call learns to ignore, and that is worse than one that is occasionally wrong. The noise budget is the design goal, and every step protects it.

★ Finale

End to end

One metric's life: emitted, ingested, stored at two resolutions, charted on demand, and — when it spikes and stays — paged once to the on-call, with the noise collapsed along the way.

  1. 1
    The whole system

    Every piece in one frame. Services emit metrics; the agents gather them; ingestion writes them into the time-series store at two resolutions; dashboards read a window on demand; and the rule engine watches the live series, dedups, groups, and routes to the on-call. One store, three ways to read it.

  2. 2
    Emitted, ingested, stored

    A service emits a sample — its request rate, tagged with its name, host, and region. The agent gathers it, ingestion parses and tags it, and it is appended to the series in the store. The same sample is also fed into the downsampled copy, so the long window is being built even now.

  3. 3
    Charted on demand

    A dashboard opens a window over that metric. The query service resolves the series, picks the resolution for the span, reads the range, and returns a line that fits the view. The read is bounded by the window and the resolution, so the chart is instant even over a busy metric.

  4. 4
    Spiked, and paged once

    Now the metric spikes and stays. The rule engine sees the condition hold for its duration and fires. The dedup collapses the repeated firings into one active alert, the router sends it to the on-call, and the ack stops the re-page. One real problem, one page — the noise budget held.

🌐 In the wild

In the wild

Metrics monitoring is the connective tissue of every on-call operation. The boxes below are anchored to the classes of well-known systems that run each piece — an illustrative mapping, not a claim about any one product's internals.

  1. 1
    The pattern, piece by piece

    Each box is a standard building block of an observability backend. Anchoring them to the classes of production systems that run that piece turns the abstract design into 'the shape behind the dashboards your on-call trusts'.

  2. 2
    Why the same store keeps winning

    Independent monitoring systems converge on the same pieces because each one removes a real failure: the time-series store removes the general-database overhead, the downsampling removes the slow long-window query, the duration removes the spike false-positive, the dedup removes the re-page storm, and the lifecycle removes the resolved-but-still-paging failure. That convergence is the evidence the design is load-bearing.