Skip to content
SD-17 · Back to the write-up

Design a Server Metrics Collector

Agents push batches through a durable log into a compressed time-series store; rollups and a cache keep queries and alerts fast.

Follow a request

Sources
Edge
Pipeline
Storage
AgentsOn 50,000 servers
EngineersDashboards
Ingest gatewaysQuotas, labels
Query serviceIndex, merge
Ingest log64 partitions
TSDB writersPer-series appends
Alert evaluator500,000 rules
NotifierGroup, dedupe
TSDB shards16 × 3, 15 days
Query cacheAligned steps
Object storageBlocks, rollups
Downsampler5 min, 1 hour
1agents → ingest · POST /v1/writeEvery 10 s, the agent on web-42 sends one snappy batch of 512 samples.1 / 6

The numbers, at a glance

Compression is the whole game1.5 bytes a sample, against 60 bytes as a row
Without a time-series format, a single day is 40 times bigger.
Points read for a 30-day panelPer series, by source
Who reads the data?Out of every 18 queries…
1 dashboard query ≈ 1,000/s17 alert queries ≈ 16,700/s

A batch, in order

The agent gets 204 once the log has the batch; storage happens after.

Agent
Gateway
Ingest log
Writer
TSDB replicas
1 POST /v1/write (512 samples)
2 append, acks=all
3 stored on 3 brokers
4 204
5 consume partition
6 append WAL + head
7 2 of 3 confirm
8 commit offset
RequestResponseAsync, does not block

How samples reach storage

The decision this question is really about.

Central pull
Good in one network
scrapers × N
GET host:9100
NAT, firewalls
+ Knows when a host is down.− Must reach 50,000 hosts across networks.
Push to storage
Fragile
agent
INSERT 2.5M/s
store backs up
+ Few parts.− Bursts and slowness hit everyone.
Push through a log
Our pick
agent batch
gatewaylog × 3
writers → TSDB
+ Absorbs bursts, replays after crashes.− More parts to run.

How it grows

Add a box only when a number forces you to. Highlighted boxes are new at each stage.

Stage 1 · ≈ 10,000 samples/sMake it work
Agents
App server
SQL database
A row per sample in SQL. Fine for 200 servers.
Stage 2 · ≈ 250,000 samples/sUse a time-series store
Agents
Load balancer
Gateways × 2Query service
TSDBSeries index
Compressed series and a label index.
Stage 3 · ≈ 2.5M samples/sBuffer and keep history
Agents
Load balancer
Gateways × 8Ingest logWriters
TSDB × 48Series indexObject storageDownsampler
A durable log, 16 shards, object storage and rollups.
Stage 4 · + 17,700 queries/sAlert and query
AgentsEngineers
Gateways × 8Query serviceAlert evaluatorNotifier
Ingest logWritersQuery cache
TSDB × 48Object storage
Own alert path and a query cache.
Was this walkthrough useful?Your vote tells us what to improve next.