Untitled Lesson
Skill Matrix
UNLOCK NODES BY LEARNING NEW TAGS.
Why is a histogram generally more useful than a simple average for measuring request latency?
💻 Code Challenge | +75 XP
Instrument an Express app with RED metrics (request rate counter, error counter, and duration histogram, each labeled by method and status) and expose them on a /metrics endpoint for Prometheus.
A metrics backend started running out of storage and slowing down after a new metric was added that includes a raw user ID as a label. Reorder the steps to fix the cardinality problem.
Task: Reorder the blocks in logical sequence to solve the problem.
A.D.A. Interface
Adaptive Didactic Assistant

Pascual Vila
Frontend Instructor // Code Syllabus
The Error //
Adding a high-cardinality label (raw user ID, full URL, IP address) to a metric
// Wrong: unbounded cardinality, one series per user
requestCounter.inc({ userId: req.user.id });
// Correct: bounded set of possible values
requestCounter.inc({ method: req.method, status: res.statusCode });The Solution //
Each unique combination of label values creates a separate time series in the metrics backend — a label with millions of possible values (like a user ID) can create millions of time series, overwhelming storage and dramatically slowing down queries. Keep labels limited to a small, bounded set of known values.
The Error //
Relying only on average latency to judge whether a service is performing well
// Misleading: average looks fine, hides slow outliers
const avgLatency = totalDuration / requestCount;
// Correct: reveals the real distribution
const p99 = histogram.percentile(99);The Solution //
An average can look perfectly healthy while a meaningful fraction of requests are experiencing very poor latency — a small number of very slow outliers gets diluted by many fast requests. Use a histogram and look at percentiles (p95, p99) to see the actual distribution, not just the mean.