The Prometheus Cardinality Bomb: How to Prevent It Before It Blows Up
Blog post from OpenObserve
The narrative describes a critical incident where a minor change in instrumentation code led to a catastrophic failure in a Prometheus time-series database, highlighting the dangers of high cardinality in metrics. A developer's addition of a `user_id` label to the main request counter created an overwhelming number of unique time series over time, causing the system to run out of memory. This phenomenon, termed a "cardinality bomb," occurs when labels with potentially infinite unique values are used in metrics, leading to exponential growth in memory usage. The text explains that while metrics are designed for aggregation and low-cardinality labels, high-cardinality identifiers like user IDs should be treated as trace attributes instead. It suggests strategies to manage and mitigate cardinality issues, such as pre-aggregating data, using trace backends for high-cardinality data, and employing alternative storage solutions like columnar backends that are not constrained by in-memory limitations. Ultimately, the text underscores the importance of thoughtful label selection to prevent system instability and suggests a balanced approach using Prometheus for real-time monitoring and other backends for high-cardinality data.
| Trend | Post Mentions | Total Month Mentions | Posts | Companies | MoM |
|---|---|---|---|---|---|
| Observability | 6 | 3,204 | 716 | 172 | +14% |
| OpenTelemetry | 4 | 622 | 137 | 51 | +51% |
| Kubernetes | 2 | 1,840 | 308 | 106 | +33% |
| Real-time | 1 | 6,457 | 1,307 | 242 | +28% |
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.