Monitoring glossary
What is metric cardinality?
Cardinality is the number of unique time series a metric creates. Add the wrong label and one metric becomes millions of series, with the bill and slow dashboards to match.
3 min read9 sectionsUpdated
On this page
How series multiply
A metric such as http_requests_total with labels route, status and pod creates one series for each combination actually seen. The worst-case count is the product of the label cardinalities:
| Labels | Distinct values | Series |
|---|---|---|
| route | 50 | 50 |
| route × status | 50 × 5 | 250 |
| route × status × pod | 50 × 5 × 20 | 5,000 |
| … × user_id | × 100,000 | 500,000,000 |
Labels to avoid on metrics
- User, session, order or request IDs: unbounded.
- Raw URLs such as
/orders/84213: use the route template/orders/:id. - Email addresses, IPs, full user agents: unbounded and personal.
- Timestamps or random values: every sample becomes a new series.
- Error messages with embedded values: normalize to an error type.
Where detail belongs instead
Metrics are for aggregates: how many, how fast, how often. Detail about individual requests belongs in traces and logs, which store one record per event and are designed to be searched by high-cardinality fields. The pattern that works: a low-cardinality metric raises the alert, and its exemplars or the APM view lead you to the individual traces with all the detail.
Controlling cardinality
- Review new labels in code review, asking "how many values can this take?"
- Normalize routes in instrumentation. APM tools such as VitalRix replace IDs, UUIDs, tokens and dates in routes with placeholders.
- Drop or rename labels in a Collector with the attributes or transform processors before export.
- Watch your series count and ingest volume. In VitalRix, usage controls show daily metric points and let you set caps so one bad deploy cannot run up the bill.
Fixing a real cardinality problem
A team adds path as a label on their request counter. After a week the metric has 380,000 series, because every product page, search query and tracking parameter produced a new path. Dashboards slow down and the bill doubles.
The fix has three parts: replace path with the route template (/products/:slug), drop query strings entirely, and add an allow-list of values for any label that comes from user input. The series count falls to about 600 and nothing useful is lost, because per-request detail is still in traces.
Is high cardinality always bad?
In metrics, it is costly. In traces and event data, it is what lets you find problems that only affect one customer or build, so modern observability tools embrace it there.
How do I find the metric causing the problem?
Count series per metric name in your backend, then per label. Usually one label on one metric accounts for most of the growth.
Related reading
- Prometheus high cardinality: how to find and fix it: Find and fix Prometheus high cardinality: use the TSDB status page and promtool, identify runaway labels and drop them with relabeling rules before ingestion.
- Service level indicators (SLIs): Save an SLI once from uptime checks, API latency or errors. See it over the last hour, day, week and month, and build SLOs and SLAs on it.
- OpenShift monitoring for application teams: Monitor applications on Red Hat OpenShift: pod resources against limits, restarts, route availability, built-in cluster monitoring.
- A Grafana Cloud alternative: VitalRix vs Grafana Cloud: VitalRix vs Grafana Cloud: building blocks you assemble versus a ready-made monitoring product, compared on dashboards, traces, logs and incidents.
- Prometheus vs Datadog: Prometheus vs Datadog compared: self-hosted open source metrics against a SaaS platform, covering cost, scaling, alerting, dashboards and team effort.
- AWS monitoring with CloudWatch metrics: Monitor AWS workloads: which CloudWatch metrics matter for EC2, RDS, ELB and SQS, the IAM permissions to read them and the alerts to set.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.