Finding and fixing high cardinality in Prometheus

Find the metrics and labels that inflate Prometheus series counts using the TSDB status API and promtool tsdb analyze, then fix them with relabeling, instrumentation changes and limits.

On this page

Finding and fixing high cardinality in Prometheus starts with knowing which label is growing

When a Prometheus server's memory, disk use or query times keep climbing, the usual cause is that the number of series keeps growing. Cardinality is the count of unique label combinations across all metrics, and every new value of any label multiplies the series a metric produces. A metric with a method label and a status label has a few series per target. Add a user_id or a request path label with thousands of distinct values and the same metric can produce hundreds of thousands of series. Prometheus instrumentation guidance suggests keeping cardinality below 10 for most metrics and investigating alternatives for any metric above 100 or with the potential to grow that large (Prometheus instrumentation best practices). Treat that as a review threshold, not a hard rule, and compare your own estimates against it.

Start this work in one of two situations: before a series limit or memory ceiling is reached, when a growth trend is visible on the server's own metrics, or after an out-of-memory restart, when the cause must be found quickly. The decisions to make early are who owns each job and whether the team wants limits enforced at scrape time. Prometheus is licensed under Apache-2.0 and has no paid edition of the server, so the cost of this work is engineering time and the infrastructure that absorbs the extra series. Ask any partner for a fixed scope covering the series review, the fixes, the limits to add and the verification run, and confirm who will own the relabeling rules afterward, since those rules need maintenance as applications change.

Before changing anything, confirm which series are growing and where they come from. Check your server version and the retention and memory settings you run, then confirm which metrics are on the scrape path that your team controls. Plan to record the current series count and the trend over at least one normal business cycle, so a fix can be shown to work. Prometheus is designed to value reliability over precision, so an estimate from the server's own status is good enough to rank the worst offenders, but treat each figure as something to verify in your environment rather than a benchmark.

Which fix fits which cardinality cause

This table compares the main levers for cutting series counts: instrumentation label changes, scrape-time relabeling, per-job limits and recording rules. Read each row by the cause you found, then check the cost in lost detail and whether the fix needs a code change or only a configuration change.

LeverWhen it fitsCost in lost detailChange needed
Remove or change labels in instrumentationA label holds unbounded values such as user IDs, request IDs or full URLs with embedded identifiersPer-value breakdown disappears for every dashboard and alert that used the labelApplication code change, then a redeploy of the service
metric_relabel_configs drop or keep rulesOne metric or label family from a target is unneeded, or a single label should be removed at scrape timeDropped series are gone from storage going forward, and existing data stays until it ages outConfiguration change in the scrape job, applied by a reload
sample_limit and label limits per scrape jobA single target or deployment suddenly exposes far more series than its normal baselineA scrape that exceeds the limit is rejected entirely, so the whole target can go missingConfiguration change in the scrape job, with a check of how failed scrapes surface
Recording rules that aggregate before storageDashboards and alerts only need totals or per-service rollups, but raw series are kept at full label detailRaw per-instance detail is no longer queryable from the recorded series, so keep raw data where incidents need itConfiguration change in rule files, but the source metrics still get stored
Dropping metrics at the source exporter or libraryA library or exporter emits metric families nobody reads, and it can be turned offOnly what is switched off is lost, which makes this the most targeted cutConfiguration or flag change in the exporter, or a code change if the library has no switch
Reducing scrape frequency or target countSeries grow because of many targets rather than many labels on each targetLower resolution and slower detection of short spikesConfiguration change in the scrape interval or target discovery rules

How to find the top series contributors with the TSDB status API

This sequence confirms that series count is growing, names the metrics and label pairs responsible, and then shows which label has the most distinct values inside a block. The output is a short list of candidate metrics and labels to fix.

  1. Confirm series growth in head statistics

    Start by checking whether the series count is actually rising before you hunt for causes. Query the Prometheus metrics that report active head series and compare the value against a baseline from a period when the server was healthy, using your existing dashboard or a direct query in the expression browser. Note the time when the rise began, because it narrows the deployment, job or exporter change to inspect. The step is done when you can state the growth rate and the start time in your own words, and when you have confirmed that the rise is in head series rather than a scrape or dashboard artifact.

  2. Enable the admin API deliberately

    The TSDB status endpoint sits under the admin HTTP API, which is disabled by default. Enable it only for the duration of the investigation by starting Prometheus with the --web.enable-admin-api flag, or confirm that an existing deployment already has it set, and record who made the change. Because the admin API can run destructive operations, place the web endpoint behind network restrictions or an authenticating reverse proxy, and disable the flag again when you finish. The step is done when a request to the status endpoint from an approved host returns data and the access path is documented for your change record.

  3. Query top series by metric and label pairs

    Call the TSDB status endpoint, which returns the metric names with the most series and the label name and value pairs that appear most often. Save the response to a file so you can compare it with later runs. Read the top entries for metric names first, then the label pairs, and check whether one metric or one label value accounts for most of the total. The step is done when you can name the top metric by series count and identify at least one label name and value pair that appears on a large share of its series. If the top list is dominated by a single job, record that job name for the next step.

  4. Identify the label with the most distinct values

    The status output shows how many series each metric has, but it does not show which label is driving the count. For that, run promtool tsdb analyze against one block directory from the data path of the server, choosing a block that covers the period of growth. Pass the metric name you identified in the previous step as the selector so the output focuses on that metric's labels. Look for the label with the highest number of distinct values, since a label with thousands of values, such as a user ID, request path or pod name, is the usual cause. The step is done when you can name the label that has the most values for the top metric and give its approximate value count from the tool output.

  5. Check the top metric against instrumentation guidance

    Compare the metric and label you found with the Prometheus instrumentation guidance on cardinality. The project suggests keeping cardinality below 10 for most metrics and investigating alternatives for any metric over 100 or with the potential to grow that large. Decide whether the offending label is an unbounded value that should not be a label at all, or a bounded value that the scrape job is multiplying through too many targets. Ask the owning team which code path adds the label, and confirm the commit or release where the growth started. The step is done when each candidate metric is marked as a code fix, a configuration fix or an accepted cost, with an owner named.

  6. Record findings and disable the admin API

    Write down the top metrics, the label names with the most values, the scrape jobs involved and the time window you analyzed. Keep the saved status responses and the promtool output with the change record so the team can repeat the comparison after a fix. Once the evidence is captured, turn off the admin API flag if you enabled it for this work, and confirm that the endpoint no longer answers from outside the approved host. The step is done when the findings are stored with the change record and the admin API is back to its prior state, with the change logged.

Fixing the cause: relabeling, instrumentation or limits

When a third-party exporter or scrape job emits labels you do not need, the cleanest fix is usually to remove those labels at ingestion with metric_relabel_configs. This runs after the scrape and before samples are stored, so you can drop noisy labels or whole metrics without changing the exporter. Use labeldrop to remove specific label names, and labelkeep when only a short allowlist should survive. Test each rule on one job first, because dropping a label that distinguishes series can merge them and produce duplicate samples or misleading totals.

  • Identify the label first: Use the TSDB status API to confirm which label name drives the count before writing a rule.
  • Prefer labelkeep for noisy exporters: An allowlist protects you when the exporter adds new labels in a later version.
  • Use labeldrop for a known label: Remove a single high-cardinality label such as a per-connection or per-session identifier.
  • Drop whole metrics where appropriate: A drop action on a metric name removes series you never query.
  • Check for collisions: Confirm that the remaining labels still uniquely identify each series.

Before changing configuration, confirm in your running Prometheus version how relabeling actions and their ordering behave, and check the exporter documentation for the labels it can emit.

How the investigation moves from symptom to fix

The investigation starts with a rising series count or memory use on the Prometheus server. Engineers read the head statistics and the TSDB status API to find which metric names and label pairs hold the most series, then trace the top offender back to the scrape job that exposes it. From there the fix is chosen: relabeling at scrape time to drop or keep labels, an instrumentation change in the application, a recording rule for an expensive expression, or a limit that stops the next growth. The last step is to confirm the series count falls and to alert on future growth so the problem is caught early.

Decision path from a rising series count to a verified fix and a growth alert.

Security and operational risks when changing cardinality

Changing cardinality touches the admin API, query results, scrape health and stored data, so each change can create a new problem while fixing an old one. The cards below cover the risks to check before and after relabeling, label removal and analysis work on a production Prometheus.

Admin API exposed during analysis

Turning on the admin API so you can inspect series is the riskiest shortcut in this work. The --web.enable-admin-api flag enables destructive operations, and the Prometheus security model says these endpoints are disabled by default for good reason. Enable it only for the analysis window, restrict network access to the listener, and turn it off again. Check that no reverse proxy forwards admin paths to users who should not reach them.

Security model docs

Dropped labels merge series

Removing a label that looks noisy can make distinct series collapse into one, so an alert expression that once compared instances may now average or sum unrelated values. Before dropping a label, search your alert rules and recording rules for every use of it. Compare alert results on a staging copy with the label removed to confirm the rule still fires on the same conditions.

Relabeling silently drops targets

A drop or keep rule written in the wrong place can remove whole scrape targets without any error in the logs. The target simply stops appearing, which can look like a healthy service with fewer series. After each relabeling change, compare the number of active targets per job before and after the change, and confirm the up metric still reports every expected instance.

Relabeling leaves stored blocks intact

Relabeling only affects samples scraped after the change. Series already written to existing blocks keep their old labels and continue to inflate counts and storage until retention removes them. Expect the high-cardinality series to remain visible in historical queries for the length of the retention window, and plan a separate removal step if the data must go sooner.

Sensitive values in labels

Values such as user IDs, email addresses, tokens or internal hostnames placed in labels are copied into every series and every stored block, and dropping them later does not erase what was already written. Remove these values at the instrumentation source, not only in relabeling. Review label values during code review for new metrics, and confirm with your security team which fields count as sensitive under your policies.

Common questions about cardinality work in Prometheus

How much effort does a cardinality review take in Prometheus?

The effort depends on how many scrape jobs the server runs, how many teams and services push or expose metrics, and how many of those metrics carry labels that were never reviewed. A small server with a few jobs and one owner can be reviewed in a focused session. A server that scrapes dozens of jobs owned by several teams needs time to inventory each job, match top series counts to owners, and test label changes before they reach production. Ask any partner for a written scope that lists the jobs in review, the number of teams involved, and the test environment used for relabeling changes, since those three inputs drive most of the quote.

Can our own team find and fix high cardinality without outside help?

Often yes, if the team has someone comfortable with PromQL and the Prometheus HTTP API. The core tools are the TSDB status endpoint, which reports the metric names and label pairs with the most series, and promtool tsdb analyze run against a copy of the data directory. The harder part is ownership: fixing a label usually means changing application code in another team's service, and that work stalls without agreed owners and a deadline. Teams that lack a dedicated Prometheus engineer, or that need to change many services at once, often bring in a partner for the review and leave the fix list with their own developers.

What access and inputs does a cardinality review need from us?

The review needs read access to the Prometheus server and its HTTP API, a way to read the TSDB status output, and a copy of the data directory or a recent snapshot so analysis does not load the live server. It also needs a named owner for each exporter, service and job, because most fixes are instrumentation changes that someone must make. A test Prometheus with the same scrape configuration is needed to check that relabeling keeps the metrics people depend on. Confirm with your platform team whether admin endpoints may be enabled for the work, and keep them disabled in production once the review ends.

Does a managed Prometheus service remove the cardinality problem?

No. A managed or remote-storage service changes where samples are stored and who operates the storage, but it still ingests every series that Prometheus sends. High cardinality raises ingestion, query and storage costs on any backend, and many hosted services bill or limit on series or samples, so unreviewed labels can become a bill rather than an outage. Before choosing a service, ask how it prices active series, what limits apply per tenant, and whether it offers per-series or per-label reporting, then run the same cardinality review on your own instrumentation.

What happens to data that is already stored when we drop high-cardinality series?

Relabeling and instrumentation changes only affect samples scraped after the change. Series already in the local TSDB stay on disk until retention removes them, which is 15 days by default and can be set by time or size. To remove existing series early, the delete_series admin API can be used, but it requires the admin API to be enabled and it leaves tombstones that must be cleaned to reclaim space. Before deleting anything, back up the data directory, because deletion cannot be undone and may remove series that dashboards or alert rules still query.

Which metrics should keep their labels when we cut cardinality?

Keep labels that answer the questions your dashboards and alerts depend on, and remove labels whose values are unbounded, such as user IDs, request IDs, full URLs or raw error messages. The Prometheus instrumentation guidance suggests keeping cardinality below 10 for most metrics and investigating alternatives for any metric above 100 or likely to grow that large. Build a list of metrics with their label sets, the owner, the alerts and panels that use them, and the decision for each, so the team can agree changes before they are deployed.

Will fixing cardinality affect our alerts and dashboards?

It can, if a dropped label is used in an alert rule, a recording rule or a panel. A label removed from a metric changes the series that queries match, so an alert that groups or filters by that label may stop firing or fire for the wrong set of series. Check every rule and dashboard that references a changed metric, update them in the same change, and compare alert behavior on a test server before rolling out. Clear communication with on-call and dashboard owners is part of the work, not an extra step.

Why series growth is hard to see until it is too late

Prometheus creates a separate series for every unique combination of metric name and label values, so a single unbounded label such as a user ID, request path or container hash does not add one series, it multiplies the existing ones. Each series costs storage on disk, memory in the head block and CPU time at query time. The growth is gradual at first because each new value arrives as an ordinary sample, nothing fails, and dashboards keep loading. The first visible sign is often a memory increase or a slow query weeks later, which makes the source hard to trace back to one label change.

Recent data lives in the head block, which is held in memory and backed by the write-ahead log in the data directory, and it is flushed into two-hour blocks on disk. A spike in new series therefore shows up first as growing head memory and WAL size, before any block is written. Local storage is single-node and not clustered or replicated, as the Prometheus storage documentation explains, so the same server holds the only copy of that data and absorbs the full cost of the spike. Confirm with your team how much memory headroom each Prometheus server has above its normal head size, because that headroom is what decides whether a spike becomes an outage.

Because the failure is local, the first step is to watch the series count per server before a problem reaches the alerting path. Track the number of series in the head and the rate at which new series are created, and set a threshold that alerts a platform owner while there is still time to act. Your team should also decide who owns that alert and which scrape job or instrumentation change it points to, since the fix usually belongs to whichever team added the label. Without that ownership, the spike is noticed during an incident rather than during the change that caused it.

Instrumentation habits that prevent cardinality from returning

Cleaning up existing series only holds if the code that creates new series stays disciplined. The four habits below are the checks that stop a fixed metric from growing back, and each one applies at the point where a developer adds or changes a metric.

Name labels from bounded sets

Every label should draw its values from a small, known list such as HTTP method, status class, job name, region or queue name. Before merging, list the possible values for each label and confirm the list cannot grow with traffic, tenants or deployments. If a label's values come from a configuration file that operators edit, document who controls that file. A label with an unbounded set multiplies every other label on the same metric, so one unbounded label can turn a small metric into thousands of series.

Typical cardinality target
10
Instrumentation best practices

Keep identifiers out of labels

User IDs, client IP addresses, raw URLs with path parameters, session tokens and request IDs produce a new series for almost every request or customer. Use logs, traces or event pipelines for those values instead. When a route must be grouped, record the route template such as /orders/{id} rather than the concrete path. Review each label name in a new metric for words like id, ip, path, url or session, and reject them unless the owning team can show a bounded value set.

Prefer histograms over per-value labels

Teams often add a label for each latency bucket, customer tier or payload size to see distributions. A histogram with fixed buckets stores those distributions in a bounded set of series per label combination, and it supports quantile estimation in PromQL. Choose bucket boundaries from expected latency or size ranges and confirm them with the team that will query the metric. Avoid a histogram per customer or per endpoint unless the endpoint set is fixed and small.

Investigate above this
100

Review new metrics in code review

Add a checklist item to pull requests that add or change metrics: the label names, the expected value count for each label, and the growth path if a service scales out. Reviewers should ask what happens to the series count when traffic doubles or a new tenant onboards. Any metric whose estimated cardinality is above 100, or could grow that large, should trigger an alternative design before merge. Record approved metrics in a shared catalog so future changes are compared against the same baseline.

Rerun the series check after releases

A label that was safe in one release can become unbounded after a feature adds a dimension. After each release that touches instrumentation, compare the series count for the affected jobs with the count from the previous release using the TSDB status API. A sudden step up in one metric name points to the change. Ask the team that owns the service to confirm the source of new label values before the next rollout.

What a DeployOpen cardinality review covers

A DeployOpen cardinality review starts from the current series profile of your Prometheus server, not from a generic checklist. We work with your team to pull the TSDB status data, confirm which scrape jobs and which labels account for the largest share of active series, and agree which of those series are needed for alerts, dashboards and capacity planning. The output of this phase is a written list of offending jobs and labels, each with the owning team, the reason it grows, and the expected effect of the fix. Your team keeps ownership of the decisions about what to drop, because only the people who build and alert on a metric can say whether a label is safe to remove.

Once the findings are agreed, the fix plan is written down before any change is made. The plan can include relabeling rules in the scrape configuration, per-job sample_limit values so one bad deployment cannot flood the server, and instrumentation handoffs for the teams whose code creates unbounded label values, such as user IDs or request paths. Each item names the file or service it touches, the test that shows the series count dropped, and the rollback step. We implement the relabeling and limit changes in your configuration under your change process, and we write the instrumentation guidance that your developers apply in their own code.

Most engagements are fixed-scope, so the scope, deliverables and timelines are agreed in writing before work starts. A quote follows from that written scope, and it depends on how many jobs and teams are involved, how much of the configuration is managed as code, and whether instrumentation changes are included or handed to your developers. Ask for the quote to list each review phase, each configuration change, and any retest or follow-up review as separate lines. Ongoing checks on series growth can be covered by a retainer if your estate keeps adding services.

How DeployOpen scopes, delivers and supports Prometheus cardinality work

DeployOpen approaches high cardinality as a measured engineering task on your own Prometheus servers, starting with an inventory of which metrics and labels drive series growth. Each engagement is fixed-scope, with the findings, fixes and handover agreed in writing before work starts.

How we scope

  • Review current series counts per metric and per scrape job on your Prometheus servers.
  • Agree which teams, exporters and instrumented applications are in the written scope.
  • Confirm the target outcome, such as a series budget per job, and the change window for fixes.

How we build

  • Identify offending labels with the TSDB status API and promtool tsdb analyze, then trace each to its source.
  • Draft relabeling rules and instrumentation changes, and test them against a copy of current scrape output.
  • Apply sample and label limits per scrape job so new growth is contained while fixes roll out.

How we hand over

  • Document each finding with the metric, label, owner, evidence and the fix applied.
  • Deliver recording rules or dashboard changes that keep queries working after labels are removed.
  • Walk your platform and application teams through the runbook for checking cardinality after releases.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Retesting after each new service or exporter is added is included in the agreed scope where stated.
  • Ask us to confirm in writing which support hours, response terms and retest rounds the retainer covers.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.