http_requests_total carries the labels pod (200 values), endpoint (5) and code (5), so about 5,000 series. A developer wants to add a user_id label (50,000 active users) "so we can see per-customer error rates". What happens if they do, and where does that detail belong?
- It is fine as long as the scrape interval is lengthened, since fewer scrapes means fewer series. The interval changes samples per series, not the number of series; cardinality is the count of distinct label sets, and memory scales with that count.
- Series count is bounded by the product of label cardinalities — up to 5,000 × 50,000 ≈ 250 million series — and every active series costs a few KB of memory plus index entries, so Prometheus runs out of memory and scrapes start failing. Per-customer detail belongs in logs or traces indexed by the id (or in exemplars); metric labels stay bounded enumerations. Each distinct label set is a separate time series that exists from the moment it is scraped; multiplying by an unbounded identifier multiplies memory, index size and scrape time.
- This is exactly what labels are for — add
emailtoo so support can search by customer. Unbounded identifiers (user, email, request id, raw path) are the canonical cardinality bombs; they belong in logs and traces, which are indexed by id and priced per byte, not per series. - Nothing dramatic — labels are query-time filters, so the cost is only paid when someone actually queries by
user_id. A label set is materialised as its own series at scrape time, stored in the head block and indexed, whether or not anyone ever queries it.
Each unique label set is its own time series, so a user_id label multiplies memory until Prometheus dies; per-user detail belongs in logs or traces.
A time series in Prometheus is one metric name plus one unique combination of label values. Every active series holds a head chunk, an entry in the in-memory index and the symbol tables, and is written to the WAL — a few kilobytes each. Adding a label whose values are user ids turns 5,000 series into up to 250 million, so memory grows by four orders of magnitude, scrapes slow down, and the process is OOM-killed; on restart it replays the WAL and dies again. The rule is that label values must be bounded enumerations you could list (endpoints, codes, regions). Per-request or per-user detail is what logs and traces are for; an exemplar can link a histogram bucket to one trace id without creating a series per user.
Treating labels as free query-time filters. Every distinct label set is a series that costs memory from the first scrape, whether or not anyone ever queries it.