When to reduce metric cardinality in OpenTelemetry pipelines
Reduce metric cardinality when your metrics bill or Prometheus-compatible back end grows faster than traffic. In most cases the cause is one or more attributes whose values are unbounded, such as user IDs, session tokens, full URLs with path parameters, or request IDs copied into metric labels. Cardinality is the number of distinct time series produced by every combination of attribute values, so a label with millions of possible values multiplies the series count of every metric it touches. Growth that tracks the number of users or distinct URLs, rather than the number of services, is the signal to investigate.
OpenTelemetry is a collection framework: its SDKs and the Collector generate, process and export telemetry, but it does not store or query it. Storage and cost sit in the back end you export to, so the fix is usually in the pipeline or the instrumentation, while the bill is set by the back end's pricing and retention. Before changing the Collector, check the source: an attribute added in application code will keep producing series unless the SDK stops recording it. Confirm with your back end's documentation how it charges for series or samples, and whether it enforces any series limit, because those rules decide how much a given attribute costs you.
Act in the Collector when the high-cardinality attribute is needed for traces or logs but not for the metric, or when you cannot change the code quickly. Fix instrumentation first when the attribute is a mistake, such as a URL that was never templated or an identifier recorded as a metric label instead of a span attribute. A quick way to decide is to list the top metrics by series count in your back end, then confirm for each whether any query or alert depends on the attribute. Confirm the exact metric names and query usage with your own dashboards before removing anything, since a dashboard that filters on a user ID will break silently.
Ways to remove or reshape high-cardinality attributes
This table compares five ways to remove or reshape high-cardinality attributes, showing where each runs, what it gives up and when it fits. Read it by choosing the row that matches where the attribute originates, then check the loss column before dropping any dimension that a dashboard or alert depends on. The main takeaway is that fixing the attribute at the source is cheapest to keep, while Collector processing is the fastest fix when you cannot change the code yet.
| Approach | Where it runs | What it loses | When it fits |
|---|---|---|---|
| Remove the attribute in the SDK | Application code, through instrumentation settings or view configuration | The dimension is gone for every backend and every signal, so it cannot be recovered later | The value has no alerting or dashboard use and the team owns the service code |
| Delete or rewrite attributes in the Collector with OTTL | Collector processors such as the attributes or transform processor, configured with OTTL statements | Detail is lost after the Collector receives it, but other pipelines can still keep it if routed separately | You need a fast fix without a code release, and you have confirmed the processor name and stability in its README |
| Bucket unbounded values into bounded groups | SDK or Collector, for example mapping status codes to classes or URLs to route templates | Exact values disappear, and the mapping rules must be maintained as new routes or codes appear | Dashboards need grouped views such as error class or route family rather than individual values |
| Move the detail to traces or logs | Span attributes or log records, with the metric keeping only low-cardinality labels | Metric queries cannot slice by the removed value, and you must query traces or logs for per-user questions | Investigators need per-request detail occasionally, but alerts and dashboards only need aggregate series |
| Aggregate before export | SDK views or Collector aggregation steps that sum or count series before they reach storage | Per-series history is lost, and quantile or rate precision depends on how the aggregation is defined | Only totals, rates or histograms are needed, and the aggregation keeps the dimensions dashboards use |
How attributes flow from the SDK to metric storage
The flow starts in instrumented applications, where the SDK decides which attributes become metric labels. Those metrics pass through an agent or gateway Collector, where attribute processors and views-style reductions remove high-cardinality keys before export. The Collector then hands series to a Prometheus-compatible back end over remote write or a scrape endpoint, while traces and logs take separate paths. Measure active series at the back end before and after each change, and check that the trust boundary sits where the Collector receives untrusted telemetry.
Metric attributes flow from SDK to storage, with traces and logs on separate paths.
Which fix fits which kind of attribute
User IDs, account numbers, tenant IDs and session identifiers create one time series per distinct value, so their count grows with your customer base. Most of the time these values belong in traces or logs, where per-request detail is expected, and not in metric labels. The usual fix is to drop the attribute from metrics in the Collector, or to keep a bounded tier label such as plan type or region instead of the identifier.
- Drop at the metric pipeline: Use the attributes or transform processor to delete
user.idorenduser.idfrom metric datapoints only, leaving spans and logs untouched. - Replace with a bounded class: Map the identifier to a small set of values, such as
customer.tierwith a fixed list, if dashboards need a split. - Risk to alerts: A per-customer alert rule built on the label will stop matching once the label is removed, so move those alerts to traces or logs.
- Check the processing order: Confirm the removal runs before any exporter, and that the same attribute is not re-added by an SDK resource attribute.
- Check for hidden copies: Search for the attribute in span metrics connector dimensions and in metric names, since these can carry it forward.
Before rollout, compare series counts per metric name for a representative window, then confirm the remaining labels still answer the questions your on-call and business dashboards ask.
Raw URL paths often embed order numbers, document IDs or email addresses, such as /orders/88123/items. Each distinct path becomes its own series, which makes the metric count unbounded. The fix is usually to record the route template, for example /orders/{id}, rather than the concrete path, and to strip query strings entirely from metric labels.
- Use the route template: Prefer the
http.routeattribute from the instrumentation library, which carries the template, overurl.pathorhttp.target. - Normalize in the Collector: For sources that only send raw paths, apply a transform rule with a regular expression that replaces numeric or UUID segments with a placeholder.
- Remove query strings: Delete query parameters from labels, since they often carry search terms or tokens.
- Risk to dashboards: Per-endpoint panels become grouped by template, so a single hot endpoint can hide differences between its parameter values. Document this change for dashboard owners.
- Check coverage: Confirm that unmatched routes, such as 404 traffic from scanners, do not fall back to raw paths and reintroduce the problem.
Illustrative example: a path such as /users/4471/orders/9920 should appear as /users/{id}/orders/{id} in metrics. Verify the rule against a sample of real request logs before enabling it.
Container names, pod names and request or correlation IDs change with every deployment, restart or request. Pod names in particular create new series each time a workload is rescheduled, so counts rise during rollouts and autoscaling events. Keep these identifiers in resource attributes where the backend needs them for troubleshooting, and remove them from the metric datapoints that feed long-term storage.
- Separate resource from datapoint attributes: Remove pod or instance attributes from metrics when a stable workload name is enough for the query.
- Keep the stable identifier: Retain the deployment, service or namespace name, which changes far less often than the pod.
- Drop request IDs from metrics: Request IDs should never be a metric label, so remove them where any upstream component added them.
- Risk to troubleshooting: Per-pod views stop working after the change. Ask whether on-call engineers need pod-level metrics or can use logs for that detail.
- Check restart behavior: Watch series counts during a rolling restart in a test environment, since stale series can linger until they age out of the backend.
Before rollout, confirm which dashboards pin a specific pod name and whether the Kubernetes metadata processor is adding these labels to every metric automatically.
Free-text fields such as error messages, exception strings, SQL statements, user-agent strings and search queries can contain almost any value. Even when the field looks like a short category, the text often includes timestamps, IDs or stack-specific details that make each value unique. These fields are best kept in log records or span events, and turned into a bounded category before any metric label is created.
- Classify instead of copying: Map error messages to a fixed set of error classes or exception types, such as
exception.type, which usually has a small set of values. - Truncate or hash with care: Hashing does not reduce cardinality in a useful way for dashboards, so prefer classification or dropping.
- Drop SQL text and user agents from metrics: Keep these in traces where a single request can be inspected.
- Risk to alerts: An alert on a specific error string will stop firing after classification. Rebuild it on the error class and confirm the classifier covers every case the alert was meant to catch.
- Check for fallbacks: Make sure unmatched values map to an explicit
otherbucket, so new messages do not silently create new series.
Before rollout, review a week of the top values for each free-text field and confirm that the classification keeps the top categories and the error signals your team depends on.
How to find and remove offending series in the Collector
This sequence moves from measuring which labels inflate series counts to a staged, verified change in the Collector that keeps dashboards and alerts working while cardinality falls. Each step ends with a check you can confirm before moving on.
Inventory current series by metric name and label
Start in the back end that stores your metrics. For Prometheus-compatible systems, query the series count per metric name, then break the largest metrics down by label name to see which ones carry the most series. Your team runs this, usually with access to the back end's query interface or its status and cardinality views. The step is done when you have a ranked list of the top metric names and the label sets attached to each, saved as a baseline you can compare against later.
Identify labels with the most distinct values
For each high-volume metric, count the distinct values of every label. Labels such as user IDs, session IDs, request IDs, full URLs with path parameters, and raw error messages usually have values that grow with traffic, while labels such as service name, HTTP method and status class stay small. Multiply the distinct-value counts of the labels on a metric to estimate its series ceiling, and note which metric drives most of the total. The check is a short table of label, metric, distinct value count and whether the value is bounded, which your engineers can review with the service owners.
Decide per label to drop, normalize or move
For each offending label, choose one of three actions. Drop it when no dashboard or alert uses it. Normalize it when the signal matters but the raw value does not, such as replacing a URL with its route template or grouping status codes into classes. Move it to traces or logs when someone needs the detail for investigation but metrics do not. Record the decision, the owner who agreed to it, and the dashboards and alerts that reference the label. The check is that every label on the list has a recorded decision and no alert depends on a label marked for removal.
Change the Collector configuration in a staging pipeline
Apply the decisions in a staging Collector pipeline, not production. Use attribute-manipulation processors to delete or rewrite labels, and use the transform processor with OTTL statements where a value must be normalized, such as collapsing URL paths into route templates. Place these processors in the metrics pipeline before the exporter. Validate the file with the Collector's configuration validation before starting it, then confirm the pipeline starts and that the expected processors appear in its debug output. Your team owns this work, and the step is complete when the staged Collector starts cleanly with the new configuration.
Deploy to staging and compare series counts
Send staging traffic through the modified pipeline and rerun the inventory from step one against the staging back end, or against a parallel store fed by both pipelines. Compare series counts per metric and per label with the baseline. Confirm that the removed labels no longer appear and that the count of series for each affected metric fell in the expected direction. Also check that aggregated queries return the same totals as before, since a label drop can merge series and change sums or rates. The check is a written comparison showing the before and after counts and any metric whose totals changed unexpectedly.
Verify dashboards and alerts still resolve
Before production, open every dashboard and alert rule that queries the affected metrics. Confirm that each panel returns data, that no query references a removed label, and that alert rules evaluate without errors in the rule status view. Where a label was normalized, check that the new values match the filters on the dashboard. This is a manual review with the owners of each dashboard. The step is complete when every panel and rule resolves, and any broken query has been updated or documented as intentionally retired.
Roll out to production and set a label growth check
Deploy the validated configuration to production in the same way as other Collector changes, with a rollback path to the previous configuration kept on hand. After rollout, repeat the series inventory and confirm the totals moved as the staging comparison predicted. Then add a recurring check that alerts when the distinct-value count of a sensitive label grows beyond a threshold your team sets, or when a new metric exceeds an agreed series budget. Confirm the alert fires in a test before relying on it. The step ends with a documented baseline, a named owner for the check, and a tested alert.
Security and data handling when reshaping metric labels
Removing or rewriting high-cardinality labels changes what data leaves your environment and where it is stored. The cards below cover the places where label work can leak identifiers, expose Collector configuration, or widen the attack surface of the pipeline itself.
Copied identifiers survive label removal
Dropping a user_id label from a metric does not remove the identifier if the same value was copied into another attribute, an exemplar, a log line or a resource attribute earlier in the pipeline. Before you rely on a removal, trace where the attribute was set, including SDK instrumentation and any transform rules that copy values. Check the exporters for each signal, not only the metric path, and confirm that hashing or dropping happens before any fan-out.
Secure Collector configuration storage
Collector configuration often holds backend endpoints, tokens and tenant identifiers, and label rules reveal which data you consider sensitive. Store the files with restricted access, encrypt them at rest, and use authenticator extensions for both incoming and outgoing connections rather than static secrets in the file. Ask who can change a transform rule in production and how that access is logged.
Collector security practicesBuild with only the components you need
A Collector built with the contrib distribution includes many processors and exporters that a metric pipeline never uses. Build a custom distribution with the Collector Builder that includes only the transform, filter, attribute and exporter components your configuration references. A smaller binary has fewer components to patch and review, and the component list becomes part of your change record.
Redact sensitive attributes
Use the redaction processor to remove sensitive attributes that label reshaping does not target, such as authorization headers or personal data captured in span attributes that later feed metrics. Redaction complements label rules: it removes values before export, while cardinality rules decide which keys stay. Test the redaction list against sample payloads from each service, because a new attribute name added by a developer will pass through unless the list is updated.
Localhost binding by default
Since Collector v0.110.0, server components bind to localhost by default rather than 0.0.0.0. Pipelines upgraded from older versions may still rely on the previous behavior, and a receiver that becomes unreachable can silently stop metrics that would have shown label changes. Review each receiver's endpoint setting during upgrades, and bind to a specific interface only when the network policy allows it.
Version control and review for rules
A transform that drops one label can also hide a metric series that an alert depends on, so label rules need the same review as application code. Keep the Collector configuration in version control, require a second reviewer for changes to transform and filter rules, and deploy from tagged commits. Keep a record of which rule removed which label and when, so an investigation into a missing series can be answered quickly.
Questions teams ask before reducing metric cardinality
What does reducing metric cardinality cost, and what drives the price?
The cost depends mostly on how many metric names, label keys and services are in scope, how many of those labels need changing, and what back end stores the result. Labor is the main component: someone must inventory series, agree which labels to drop or aggregate, change Collector processors or application instrumentation, then test that dashboards and alerts still work. Tooling is usually open source, so the recurring costs sit in storage, compute and the people who keep the pipeline running. Ask any partner for a quote that lists the metric inventory size, the number of services touched, the back-end type, and the testing effort, and whether the work is fixed-scope with written deliverables. DeployOpen does not publish a price list, and a quote follows from the written scope.
How long does a cardinality reduction project usually take?
Duration is set by the number of high-cardinality metrics, how many teams own the dashboards and alerts that use them, and how much change control your organization requires. The first phase, an inventory of series counts by metric and label, is often the quickest to finish, because it shows where the volume is. Changes to application instrumentation take longer than Collector processor changes, since they need code releases in each service. Testing against live dashboards and alert rules adds time when owners are slow to review. Ask for a timeline that separates inventory, change, testing and rollout, and confirm which steps depend on your teams' release calendars.
What does our team need to provide before the work starts?
Most projects need four inputs. First, a metric inventory or at least read access to the back end's series statistics, so the work starts from measured volume rather than guesses. Second, named owners for the dashboards, recording rules and alerts that depend on each metric, because someone must approve every label change. Third, access to the Collector configuration and the deployment pipeline, plus the ability to roll out changes in a non-production environment first. Fourth, access to the Prometheus-compatible back end with rights to query it and review its configuration. Confirm these access paths in writing before the schedule is set.
Can our internal platform team reduce cardinality without outside help?
Yes, many teams can, especially when one or two engineers already run the Collector and the metrics back end. The work is mostly systematic: measure series by metric and label, drop or aggregate labels such as user IDs and raw URLs, and verify that queries and alerts still return the same answers. The risks are unclear ownership of dashboards and the time it takes to change instrumentation across many services. An outside partner usually adds the most value when the inventory is large, many teams depend on the same metrics, or the platform team lacks spare capacity. Compare the internal effort against a written scope before deciding.
How do we tell whether a Prometheus-compatible back end is the real cost driver?
Start by measuring active series and ingestion rate, not total storage. Prometheus stores data in a local time series database with two-hour blocks and a default retention of 15 days, and local storage is not clustered or replicated, so a single node's memory and disk grow with series count. If series counts rise sharply after a new label appears, cardinality is the cause. If volume is steady but retention or query load is high, the cost sits in storage size, remote write targets or query capacity. Check whether you run remote write to a long-term store, since that vendor's pricing may scale with samples or series. Note that the Prometheus documentation favors reliability over precision, so a team that needs exact per-request counts should check the metric type it uses before cutting labels.
What breaks if we drop labels from metrics in production?
The most common failures are broken dashboards, alerts that stop firing, and recording rules that return different values after a label is removed. A label dropped from a counter can merge series that were previously separate, which changes rate and ratio calculations. Teams should check every PromQL query and alert expression that filters or groups by the label before the change goes live. Run the new configuration alongside the old one for a period, compare results, and keep a rollback path. Document which labels were removed and why, so future engineers do not add them back.
Does this work cover security and compliance evidence for our metrics?
Reducing cardinality changes what telemetry contains, so it can affect evidence used in audits and incident reviews. Before removing a label, confirm whether any control, retention rule or incident process depends on it. Also confirm that labels containing personal data are removed or redacted, which the OpenTelemetry security guidance supports through the redaction processor. DeployOpen prepares systems and evidence for compliance assessments, but it does not issue audit reports or certifications; independent auditors and certification bodies do that work.
Limits to confirm before changing labels
Removing attributes from metrics changes what your back end stores, what your alerts evaluate and what your dashboards can still answer. The cards below list the checks to finish in your own environment before a label change reaches production, so the savings do not come with broken alerts or lost correlation.
Collector version and processor stability
Confirm the Collector build you run, then check the stability level of each processor in your pipeline, which is documented in each component's README. Attribute processors and OTTL transform statements change behavior across releases, so pin the version you tested and note which components are marked beta or alpha. Recheck the status page before upgrading, since a label rule that worked on one release can behave differently on the next.
- Latest Collector release
- v0.163.0
Back end retention and remote write
Find out how long your Prometheus-compatible back end keeps series, whether it runs local storage or remote write to long-term storage, and whether a dropped label creates new series that double storage for a period. Local storage is single-node and not replicated, so a label change applied to one replica can leave the copies inconsistent. Ask who owns the remote write target and how it handles series churn.
- Default local retention
- 15 days
Alerts and recording rules that use the labels
Search your alerting and recording rules for every label you plan to remove, including aggregations with by clauses, dashboard queries and SLO calculations. A rule that groups by a removed label will silently return fewer series or no data, which can hide an outage. Replace or rewrite these expressions first, then confirm they evaluate correctly on test data before the change ships.
Exemplars and trace correlation
Exemplars link a metric sample to a trace ID, and that link depends on the sample surviving aggregation. Removing a high-cardinality attribute that carried a trace reference can break jump-to-trace workflows in your dashboards. Test that exemplars still appear on the panels engineers use during incidents, and decide which identifiers belong on spans and logs instead of metric labels.
Prometheus release line in use
Identify the Prometheus version your team runs and whether it is on the long-term support line. The current LTS line is 3.13, supported until July 31, 2027, while regular minor releases stop receiving bug fixes about six weeks after they ship. Behavior around label handling and relabeling can change between minor releases, so pin the version and confirm it matches the one you tested against.
Prometheus release cycleBilling model: series or samples
Ask your vendor or platform owner whether the back end bills by active series, by ingested samples, by storage volume or by query use. Series-based billing rewards removing label combinations, while sample-based billing rewards reducing scrape frequency. Note that Prometheus itself is Apache-2.0 licensed with no paid edition, so the cost you control sits in infrastructure, storage and the people running it, plus any managed service fees.
How DeployOpen scopes and delivers metric cardinality work
DeployOpen starts by measuring which metric label sets are growing fastest in your Collector pipelines and back end, then agrees a written scope for the attribute changes. The work is delivered inside infrastructure you control, with each change tested before it reaches production metrics.
How we scope
- Inventory every metric stream and identify labels such as user IDs, session IDs and raw URLs that multiply series counts.
- Agree in writing which metrics, pipelines and back-end systems are in scope, and which dashboards and alerts depend on each label.
- Engagements are fixed-scope, so deliverables and timelines are settled before any pipeline change begins.
- Confirm with your team which series counts and back-end cost data you can export so the baseline is recorded.
How we build
- Write Collector processor rules that drop, hash or normalize high-cardinality attributes, such as route templates in place of raw URLs.
- Test each rule against sample telemetry in a non-production pipeline and compare series counts before and after.
- Review which metrics should move to traces or logs, where per-request detail is better kept, and document that split.
- Build changes in a version-controlled configuration so every rule change has a review history and a rollback path.
How we hand over
- Deliver the configuration, a list of removed or reshaped labels, and the rationale for each change.
- Document the series count baseline, the post-change measurements and the dashboards or alerts that were adjusted.
- Train your platform and operations staff to run the cardinality query checks and to review new attributes before they ship.
- Provide a runbook for adding a new metric label, including the cardinality review step your team should follow.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, covering new services and Collector releases.
- Re-run cardinality checks after major application releases, since new endpoints and identifiers often introduce new label values.
- Ask any provider to confirm how changes are tested, rolled back and recorded before you agree the scope.

