[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79AH2Q99VDH46SCEXQQ6MT5":3,"skill-same:01M79AH2Q99VDH46SCEXQQ6MT5":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M79AH2Q99VDH46SCEXQQ6MT5","grafana-prometheus-cardinality-troubleshooter",null,"Diagnostic guide for active Prometheus cardinality problems — slow queries, OOMing Prometheus, high Grafana Cloud Active Series or DPM bills, \"too many samples\" ingest errors, series churn, or rapid memory growth. Walks through tsdb status endpoints, per-metric and per-label drill-downs, common-culprit galleries, and remediation paths. Use when the user is *currently experiencing* a cardinality fire. For preventing cardinality issues at the source, route to prometheus-label-strategy. For post-ingest aggregation, route to adaptive-metrics. For DPM-specific analysis, route to dpm-finder.","yhyu13\u002FAgentSkillsVault","yhyu13","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F19365678?v=4","01M79A3XCF5M26GEWS60XQQRWW","俞航","01M79A3XD7YZ779GGWS41K367S",3,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault\u002Fblob\u002Fmain\u002FSKILL\u002Fdevops\u002Ftier2\u002Fgrafana-prometheus-cardinality-troubleshooter\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: grafana-prometheus-cardinality-troubleshooter\nlicense: Apache-2.0\ndescription: >\n  Diagnostic guide for active Prometheus cardinality problems — slow queries, OOMing\n  Prometheus, high Grafana Cloud Active Series or DPM bills, \"too many samples\" ingest\n  errors, series churn, or rapid memory growth. Walks through tsdb status endpoints,\n  per-metric and per-label drill-downs, common-culprit galleries, and remediation paths.\n  Use when the user is *currently experiencing* a cardinality fire. For preventing\n  cardinality issues at the source, route to prometheus-label-strategy. For post-ingest\n  aggregation, route to adaptive-metrics. For DPM-specific analysis, route to dpm-finder.\n---\n\n# Prometheus Cardinality Troubleshooter\n\nYou are an expert in diagnosing live Prometheus cardinality problems. When a user reports a Prometheus performance, memory, or cost issue that smells like cardinality, use this guide to triage systematically.\n\nThis skill is **diagnostic and operational**. For schema design and prevention, route to `prometheus-label-strategy`.\n\n---\n\n## Before You Remediate: The One Rule\n\nUnder pressure, the tempting move is to `labeldrop` the high-cardinality label at scrape time. **Do not.** You cannot remove, at scrape time, any label that makes a series unique — not `pod`, not `instance`, not anything that distinguishes one real series from another. It looks like it stops the bleeding; it actually **breaks the data**:\n\n- Counter resets from different series get merged → `rate()` and `increase()` return garbage, often *absurdly high* values.\n- Multiple samples land on the same series per scrape → duplicate-sample \u002F out-of-order errors and **inflated** DPM, not reduced.\n- The breakage is silent (no config error) and leaves no evidence in the data of where it went wrong. Weeks later someone asks \"why is my DPM so high \u002F why is `rate()` absurd?\" and there's nothing to point to.\n\nThe only safe remediations are:\n\n1. **Drop an *entire* unwanted metric** (`action: drop` on `__name__`) — you're discarding the whole metric, not merging distinct series.\n2. **Fix the source** — stop the application emitting the bad label (the real fix for unbounded `path`, `user_id`, etc.).\n3. **Adaptive Metrics** — for structural cardinality on series you can't fix at the source. It aggregates *correctly* (counter-reset-aware, audited, reversible). This is the right way to reduce the cost of a label like `pod`. Route to `adaptive-metrics`.\n\nEverywhere below that says \"drop a label,\" read it through this rule: drop whole metrics, fix the source, or use Adaptive Metrics — never `labeldrop` a distinguishing label.\n\n---\n\n## Symptom → Likely Cause\n\n| Symptom | Likely Cause | First Action |\n|---|---|---|\n| Prometheus OOMKilled or memory growing linearly | Active series growth (often from a new bad metric or label) | [Active Series triage](#step-1-active-series-triage) |\n| Single PromQL query slow or OOMs the querier | One or more metrics in the query have high cardinality | [Per-query drill-down](#step-3-per-metric-drill-down) |\n| Remote write lagging, WAL growing | Sample throughput spike — series count OR scrape interval changed | [Active Series triage](#step-1-active-series-triage) + check scrape intervals |\n| `429 Too Many Samples` \u002F `out of bounds` errors | Hitting Mimir\u002FCortex ingester per-tenant series limit | [Per-metric drill-down](#step-3-per-metric-drill-down), find the new offender |\n| Grafana Cloud Active Series bill spiked | New metric, new label, or rollout creating churn | [Per-metric drill-down](#step-3-per-metric-drill-down) + churn check |\n| Grafana Cloud DPM bill spiked but Active Series flat | Scrape interval shortened, OR remote_write sending duplicates | DPM-side issue — route to `dpm-finder` |\n| `series_limit_per_user` errors after a deploy | Application change introduced a new bad label | [Recent change diff](#step-4-recent-change-diff) |\n| Series count grows then resets every restart | Series churn from ephemeral label values | [Churn diagnosis](#step-5-churn-diagnosis) |\n\n---\n\n## Step 1: Active Series Triage\n\n### Get the headline number\n\n```promql\n# Total active series in the local Prometheus\nprometheus_tsdb_head_series\n\n# Or for Mimir \u002F Grafana Cloud Metrics (per tenant)\ncortex_ingester_memory_series{user=\"\u003Ctenant>\"}\n```\n\nCompare to recent history:\n```promql\n# Growth over the last 7 days\nderiv(prometheus_tsdb_head_series[7d]) * 86400\n```\n\nA growth rate > a few % per day on a stable application set is a red flag.\n\n### Use the TSDB status endpoint\n\nPrometheus exposes a built-in cardinality breakdown:\n\n```bash\ncurl -s http:\u002F\u002Fprometheus:9090\u002Fapi\u002Fv1\u002Fstatus\u002Ftsdb | jq\n```\n\nReturns:\n- `seriesCountByMetricName` — top metrics by series count\n- `labelValueCountByLabelName` — top labels by unique value count\n- `memoryInBytesByLabelName` — top labels by memory footprint\n- `seriesCountByLabelValuePair` — top label-value pairs by series count\n\nThis is usually the fastest path to \"which metric \u002F which label is the problem.\"\n\nFor Grafana Cloud:\n```bash\n# Same endpoint, authenticated against the per-tenant Mimir\ncurl -s -u \"\u003Cuser>:\u003Ctoken>\" \\\n  \"https:\u002F\u002Fprometheus-prod-XX.grafana.net\u002Fapi\u002Fprom\u002Fapi\u002Fv1\u002Fstatus\u002Ftsdb\" | jq\n```\n\n---\n\n## Step 2: Read the Output\n\n### Top metrics by series count\n\n```json\n\"seriesCountByMetricName\": [\n  { \"name\": \"http_request_duration_seconds_bucket\", \"value\": 184320 },\n  { \"name\": \"go_gc_duration_seconds\",               \"value\": 80 },\n  ...\n]\n```\n\n**Heuristics**:\n- A histogram (`_bucket`) at the top is almost always the answer — those have a 14× multiplier (bucket count + 3). The fix is usually **reducing the labels on the underlying histogram at the source** (in instrumentation code), not stripping them at scrape and not touching the buckets themselves.\n- A metric in the top 5 you don't recognize → grep the codebase for it; it's likely a new feature flag or a debug metric that shipped to prod\n- The same metric showing up under multiple variants (`_total`, `_count`, `_sum`) — that's a histogram or summary, count all variants together for the true impact\n\n### Top labels by unique value count\n\n```json\n\"labelValueCountByLabelName\": [\n  { \"name\": \"url\",       \"value\": 84210 },\n  { \"name\": \"trace_id\",  \"value\": 41000 },\n  { \"name\": \"pod\",       \"value\": 1820 }\n]\n```\n\n**Red flags**:\n- Any label with >10K unique values is almost certainly a bug. The only exceptions are intentional per-target labels in massive fleets.\n- `trace_id`, `request_id`, `session_id`, `query`, `email`, `path`, `url` — these should *never* be labels. They belong in exemplars, logs, or traces.\n- `pod` with thousands of values — see [Churn diagnosis](#step-5-churn-diagnosis); recent churn often inflates this number\n\n---\n\n## Step 3: Per-Metric Drill-Down\n\nOnce you've identified a suspect metric, find which label is responsible.\n\n### Count distinct label values per label, for one metric\n\n```promql\n# How many unique values does each label have on this metric?\ncount by (__name__) (\n  count by (__name__, label_name_here) (\n    http_request_duration_seconds_bucket\n  )\n)\n```\n\nRepeat per label, or use the helper:\n\n```bash\n# Via the Prometheus HTTP API\ncurl -s \"http:\u002F\u002Fprometheus:9090\u002Fapi\u002Fv1\u002Flabels?match[]=http_request_duration_seconds_bucket\" | jq -r '.data[]' | \\\n  while read label; do\n    count=$(curl -s \"http:\u002F\u002Fprometheus:9090\u002Fapi\u002Fv1\u002Flabel\u002F${label}\u002Fvalues?match[]=http_request_duration_seconds_bucket\" | jq '.data | length')\n    echo \"${count}  ${label}\"\n  done | sort -rn | head -20\n```\n\n### Find the top label values for one label\n\n```promql\n# Top 20 path values for http_requests_total\ntopk(20,\n  count by (path) (http_requests_total)\n)\n```\n\nIf you see UUIDs, hashes, timestamps, or numeric IDs in the top values → that label has unbounded values from the source.\n\n### Per-metric series count, grouped\n\n```promql\n# Series-per-instance breakdown — if uneven, one instance is misbehaving\nsum by (job, instance) ({__name__=~\"my_metric.*\"})\n```\n\n---\n\n## Step 4: Recent Change Diff\n\nIf the cardinality fire started recently, the cause is almost always a recent change. Diff what's there now against what was there before.\n\n### List of metrics, current vs. yesterday\n\nVia Grafana Cloud cardinality dashboard, or:\n```promql\n# Current metrics\ngroup by (__name__) ({__name__!=\"\"})\n\n# Compare to last week (offset)\ngroup by (__name__) ({__name__!=\"\"} offset 7d)\n```\n\nDiff externally. A new metric near the top of `seriesCountByMetricName` that wasn't there a week ago → that's your offender.\n\n### Correlate with deploys\n\n```promql\n# Active series correlated with build_info\nprometheus_tsdb_head_series\n# Overlay with:\nchanges(app_build_info[1d])\n```\n\nA vertical step in series count aligned with a deploy is conclusive.\n\n---\n\n## Step 5: Churn Diagnosis\n\nHigh churn means series are being created and abandoned faster than they age out. Symptoms: series count keeps climbing, then drops sharply on Prometheus restart.\n\n### Churn signal\n\n```promql\n# Series created vs. removed per second\nrate(prometheus_tsdb_head_series_created_total[5m])\nrate(prometheus_tsdb_head_series_removed_total[5m])\n\n# Ratio of churned to live\nprometheus_tsdb_head_series_created_total \u002F prometheus_tsdb_head_series\n```\n\nA creation rate that materially exceeds the removal rate, sustained, means cardinality is on a one-way trip up. Common causes:\n\n| Cause | Tell |\n|---|---|\n| Pod rollouts emitting `pod` label | Churn spike aligns with deploy timing; affects pod-discovered scrapes |\n| `version` \u002F `git_sha` \u002F `image_tag` label on every metric | Churn spike on every deploy across many metrics |\n| Ephemeral hostnames in `instance` | Cloud autoscaling event timing |\n| Bug: dynamic label names | Churn climbs forever, never plateaus |\n| Application bug emitting fresh UUIDs as labels | Linear unbounded growth, no deploy correlation |\n\n### Memory impact of churn\n\n```promql\n# A churn-driven head block carries old series until tsdb compaction\nprometheus_tsdb_head_chunks\ngo_memstats_heap_inuse_bytes{job=\"prometheus\"}\n```\n\nRestarting Prometheus drops churned series but is not a fix. The fix is at the source.\n\n---\n\n## Common-Culprit Gallery\n\n### Histogram blowup\n\n**Tell**: `*_bucket` metric at the top of `seriesCountByMetricName`. Multiplier ≈ 14×.\n\n**Fix**:\n1. First, **reduce labels on the histogram at the source** — every label removed saves 14× series. Trim `path`, `method`, or `status_code` in the instrumentation code (don't `labeldrop` them at scrape — that merges distinct histograms and corrupts the buckets). For series already in Grafana Cloud you can't change, aggregate them with Adaptive Metrics.\n2. Then, reduce bucket count if appropriate (custom buckets vs. defaults).\n3. For high-resolution latency tracking, consider **native histograms** (Prometheus 2.40+) — single sparse series replaces the bucket family.\n\n### kube-state-metrics label explosion\n\n**Tell**: `kube_pod_labels` or `kube_pod_annotations` at the top, with `label_*` or `annotation_*` labels driving cardinality.\n\n**Fix**: configure kube-state-metrics with `--metric-labels-allowlist` and `--metric-annotations-allowlist`. By default it emits *all* labels and annotations as series.\n\n```yaml\n# kube-state-metrics flags\n--metric-labels-allowlist=pods=[app,team,version]\n--metric-annotations-allowlist=pods=[checksum\u002Fconfig]\n```\n\n### Path \u002F route blowup from a new endpoint\n\n**Tell**: `http_requests_total` (or framework equivalent) grew 10×+ overnight. `topk(20, count by (path) (http_requests_total))` shows hundreds of `\u002Fusers\u002F123456`-style values.\n\n**Fix**: the real fix is to **template the path in application code** (`\u002Fusers\u002F:id`) — route the user to `prometheus-label-strategy`. For series already in Grafana Cloud, **Adaptive Metrics** can aggregate `path` away correctly — route to `adaptive-metrics`.\n\nDo **not** \"normalize\" `path` with a relabel `replacement` rule — collapsing `\u002Fusers\u002F123`, `\u002Fusers\u002F456`, … into one `\u002Fusers\u002F:id` value at scrape merges distinct series and produces duplicate-sample errors and broken `rate()`. The merge has to happen at the source (templating) or post-ingest (Adaptive Metrics), never at scrape.\n\nIf you must stop a production fire *right now* and templating isn't deployable yet, the only safe scrape-time action is to drop the **entire** offending metric (you lose it completely until the code fix lands — a deliberate trade, not a silent corruption):\n\n```yaml\n# Emergency: drop the whole metric until the source is templated\nmetric_relabel_configs:\n  - source_labels: [__name__]\n    regex: http_requests_total\n    action: drop\n```\n\n### Application emitting a debug metric in prod\n\n**Tell**: A metric you don't recognize in the top 10. Grep the source — often a `_details` or `_per_request` debug metric the developer forgot to gate.\n\n**Fix**: drop entirely at scrape:\n```yaml\nmetric_relabel_configs:\n  - source_labels: [__name__]\n    regex: my_app_request_details\n    action: drop\n```\n\nOpen a ticket against the team to remove it from the code.\n\n### App-emitted labels colliding with target labels\n\n**Tell**: Series count for one job is several × what it should be. Looking at one series, you see both an app-emitted `instance=...` AND the target `instance=...` collided into something weird (Prometheus renames the conflicting one to `exported_instance`).\n\n**Fix**: the right fix is **in the application** — stop emitting `instance`\u002F`node`\u002F`host` from code; they belong to the scrape target. Confirm `honor_labels` is `false` (the default) so the target labels win.\n\nIf you need a scrape-time stopgap, you may remove a label *only* where it **exactly duplicates** a target label — that's the one safe `labeldrop`, because the target label still provides uniqueness. Scope it tightly to the duplicated names and **never include `pod`** (or any other label that is the source of uniqueness):\n\n```yaml\n# Stopgap ONLY for app-emitted duplicates of target labels.\n# Drops the `exported_*` collisions — NOT pod, which makes K8s series unique.\nmetric_relabel_configs:\n  - regex: exported_(instance|node|host)\n    action: labeldrop\n```\n\nThen the target labels from `relabel_configs` apply cleanly. Prefer fixing the app.\n\n### Federation amplifying cardinality\n\n**Tell**: A federated Prometheus or Mimir global view has way more series than expected. Each source has its own `cluster` \u002F `region` label, multiplying.\n\n**Fix**: this is usually expected — federation by design preserves source labels. If the series count is too high, federate only aggregated recording rules, not raw metrics:\n\n```yaml\n- job_name: federate\n  honor_labels: true\n  metrics_path: \u002Ffederate\n  params:\n    'match[]':\n      - '{__name__=~\".*:.*\"}'  # Recording-rule naming convention only\n```\n\n---\n\n## Remediation Decision Tree\n\n```\nCardinality fire confirmed\n│\n├── Need to stop the bleeding NOW (production OOM, ingest 429s)\n│   └── Drop the ENTIRE offending metric via metric_relabel_configs (action: drop on __name__)\n│       (also applies to Alloy\u002FAgent — same syntax)\n│       Do NOT labeldrop a distinguishing label — it breaks the data, see \"The One Rule\".\n│       Then schedule the proper fix.\n│\n├── It's a Grafana Cloud Active Series bill issue, not a perf issue\n│   ├── Cardinality is structural and you can't fix the app\n│   │   └── Route to `adaptive-metrics` skill (post-ingest aggregation rules — the safe way)\n│   └── You want metric-by-metric DPM breakdown\n│       └── Route to `dpm-finder` skill\n│\n├── It's a fixable application bug (unbounded label, debug metric in prod)\n│   ├── Short-term: drop the whole metric at scrape, OR aggregate via Adaptive Metrics\n│   └── Long-term: fix in code; route to `prometheus-label-strategy` for design guidance\n│\n├── It's histogram cardinality\n│   ├── Reduce labels on the underlying histogram AT THE SOURCE (14× win per label)\n│   ├── Reduce bucket count if appropriate\n│   └── Consider native histograms for high-resolution latency\n│\n└── It's churn (deploy-driven)\n    ├── Stop EMITTING `version`\u002F`git_sha`\u002F`instance` from app code (use info-metric for version)\n    ├── Keep `pod` — never drop it; if pod-level series are too costly, use Adaptive Metrics\n    └── Verify K8s SD relabel rules aren't mapping in `uid` or other ephemeral fields\n```\n\n---\n\n## Emergency Drop Patterns (copy-paste ready)\n\nThese are the **safe** scrape-time emergency actions: dropping an *entire* unwanted metric. They do not merge distinct series, so they don't corrupt the data.\n\n> ⚠️ There is intentionally **no `labeldrop` of a distinguishing label** and **no value-normalizing relabel** here. Both merge distinct series and break `rate()`\u002FDPM (see [The One Rule](#before-you-remediate-the-one-rule)). To reduce cardinality *without* dropping the whole metric, fix the source or use **Adaptive Metrics** (route to `adaptive-metrics`). The only safe `labeldrop` is removing a label that *exactly duplicates* a target label (e.g. `exported_instance`) — see [App-emitted labels colliding with target labels](#app-emitted-labels-colliding-with-target-labels).\n\nFor Prometheus `scrape_configs`:\n\n```yaml\nmetric_relabel_configs:\n  # Drop a specific bad metric entirely\n  - source_labels: [__name__]\n    regex: bad_metric_name\n    action: drop\n\n  # Drop a set of debug\u002Ftemporary metrics by name prefix\n  - source_labels: [__name__]\n    regex: debug_.*\n    action: drop\n```\n\nFor Grafana Alloy (`prometheus.relabel` component):\n\n```alloy\nprometheus.relabel \"drop_bad_metric\" {\n  forward_to = [prometheus.remote_write.default.receiver]\n\n  rule {\n    source_labels = [\"__name__\"]\n    regex = \"bad_metric_name\"\n    action = \"drop\"\n  }\n}\n```\n\n**Always test in staging first**, and prefer fixing the source or using Adaptive Metrics over any scrape-time drop.\n\n---\n\n## When to Hand Off\n\n- **\"Now design a label strategy so this doesn't happen again\"** → `prometheus-label-strategy`\n- **\"We need to keep these metrics but reduce cost\"** → `adaptive-metrics`\n- **\"Which metric is the most expensive in DPM terms?\"** → `dpm-finder`\n- **\"Write the PromQL to find this\"** → `promql`\n- **\"Configure this in Alloy\"** → `alloy`\n- **\"Why is my Loki slow?\"** → `loki-label-analyzer` (different system, same family of problems)\n\nThis skill's lane is **diagnosis under pressure**. Prevention, design, and post-ingest cost optimization live elsewhere.\n","# Prometheus Cardinality Troubleshooter\n\nYou are an expert in diagnosing live Prometheus cardinality problems. When a user reports a Prometheus performance, memory, or cost issue that smells like cardinality, use this guide to triage systematically.\n\nThis skill is **diagnostic and operational**. For schema design and prevention, route to `prometheus-label-strategy`.\n\n---\n\n## Before You Remediate: The One Rule\n\nUnder pressure, the tempting move is to `labeldrop` the high-cardinality label at scrape time. **Do not.** You cannot remove, at scrape time, any label that makes a series unique — not `pod`, not `instance`, not anything that distinguishes one real series from another. It looks like it stops the bleeding; it actually **breaks the data**:\n\n- Counter resets from different series get merged → `rate()` and `increase()` return garbage, often *absurdly high* values.\n- Multiple samples land on the same series per scrape → duplicate-sample \u002F out-of-order errors and **inflated** DPM, not reduced.\n- The breakage is silent (no config error) and leaves no evidence in the data of where it went wrong. Weeks later someone asks \"why is my DPM so high \u002F why is `rate()` absurd?\" and there's nothing to point to.\n\nThe only safe remediations are:\n\n1. **Drop an *entire* unwanted metric** (`action: drop` on `__name__`) — you're discarding the whole metric, not merging distinct series.\n2. **Fix the source** — stop the application emitting the bad label (the real fix for unbounded `path`, `user_id`, etc.).\n3. **Adaptive Metrics** — for structural cardinality on series you can't fix at the source. It aggregates *correctly* (counter-reset-aware, audited, reversible). This is the right way to reduce the cost of a label like `pod`. Route to `adaptive-metrics`.\n\nEverywhere below that says \"drop a label,\" read it through this rule: drop whole metrics, fix the source, or use Adaptive Metrics — never `labeldrop` a distinguishing label.\n\n---\n\n## Symptom → Likely Cause\n\n| Symptom | Likely Cause | First Action |\n|---|---|---|\n| Prometheus OOMKilled or memory growing linearly | Active series growth (often from a new bad metric or label) | [Active Series triage](#step-1-active-series-triage) |\n| Single PromQL query slow or OOMs the querier | One or more metrics in the query have high cardinality | [Per-query drill-down](#step-3-per-metric-drill-down) |\n| Remote write lagging, WAL growing | Sample throughput spike — series count OR scrape interval changed | [Active Series triage](#step-1-active-series-triage) + check scrape intervals |\n| `429 Too Many Samples` \u002F `out of bounds` errors | Hitting Mimir\u002FCortex ingester per-tenant series limit | [Per-metric drill-down](#step-3-per-metric-drill-down), find the new offender |\n| Grafana Cloud Active Series bill spiked | New metric, new label, or rollout creating churn | [Per-metric drill-down](#step-3-per-metric-drill-down) + churn check |\n| Grafana Cloud DPM bill spiked but Active Series flat | Scrape interval shortened, OR remote_write sending duplicates | DPM-side issue — route to `dpm-finder` |\n| `series_limit_per_user` errors after a deploy | Application change introduced a new bad label | [Recent change diff](#step-4-recent-change-diff) |\n| Series count grows then resets every restart | Series churn from ephemeral label values | [Churn diagnosis](#step-5-churn-diagnosis) |\n\n---\n\n## Step 1: Active Series Triage\n\n### Get the headline number\n\n```promql\n# Total active series in the local Prometheus\nprometheus_tsdb_head_series\n\n# Or for Mimir \u002F Grafana Cloud Metrics (per tenant)\ncortex_ingester_memory_series{user=\"\u003Ctenant>\"}\n```\n\nCompare to recent history:\n```promql\n# Growth over the last 7 days\nderiv(prometheus_tsdb_head_series[7d]) * 86400\n```\n\nA growth rate > a few % per day on a stable application set is a red flag.\n\n### Use the TSDB status endpoint\n\nPrometheus exposes a built-in cardinality breakdown:\n\n```bash\ncurl -s http:\u002F\u002Fprometheus:9090\u002Fapi\u002Fv1\u002Fstatus\u002Ftsdb | jq\n```\n\nReturns:\n- `seriesCountByMetricName` — top metrics by series count\n- `labelValueCountByLabelName` — top labels by unique value count\n- `memoryInBytesByLabelName` — top labels by memory footprint\n- `seriesCountByLabelValuePair` — top label-value pairs by series count\n\nThis is usually the fastest path to \"which metric \u002F which label is the problem.\"\n\nFor Grafana Cloud:\n```bash\n# Same endpoint, authenticated against the per-tenant Mimir\ncurl -s -u \"\u003Cuser>:\u003Ctoken>\" \\\n  \"https:\u002F\u002Fprometheus-prod-XX.grafana.net\u002Fapi\u002Fprom\u002Fapi\u002Fv1\u002Fstatus\u002Ftsdb\" | jq\n```\n\n---\n\n## Step 2: Read the Output\n\n### Top metrics by series count\n\n```json\n\"seriesCountByMetricName\": [\n  { \"name\": \"http_request_duration_seconds_bucket\", \"value\": 184320 },\n  { \"name\": \"go_gc_duration_seconds\",               \"value\": 80 },\n  ...\n]\n```\n\n**Heuristics**:\n- A histogram (`_bucket`) at the top is almost always the answer — those have a 14× multiplier (bucket count + 3). The fix is usually **reducing the labels on the underlying histogram at the source** (in instrumentation code), not stripping them at scrape and not touching the buckets themselves.\n- A metric in the top 5 you don't recognize → grep the codebase for it; it's likely a new feature flag or a debug metric that shipped to prod\n- The same metric showing up under multiple variants (`_total`, `_count`, `_sum`) — that's a histogram or summary, count all variants together for the true impact\n\n### Top labels by unique value count\n\n```json\n\"labelValueCountByLabelName\": [\n  { \"name\": \"url\",       \"value\": 84210 },\n  { \"name\": \"trace_id\",  \"value\": 41000 },\n  { \"name\": \"pod\",       \"value\": 1820 }\n]\n```\n\n**Red flags**:\n- Any label with >10K unique values is almost certainly a bug. The only exceptions are intentional per-target labels in massive fleets.\n- `trace_id`, `request_id`, `session_id`, `query`, `email`, `path`, `url` — these should *never* be labels. They belong in exemplars, logs, or traces.\n- `pod` with thousands of values — see [Churn diagnosis](#step-5-churn-diagnosis); recent churn often inflates this number\n\n---\n\n## Step 3: Per-Metric Drill-Down\n\nOnce you've identified a suspect metric, find which label is responsible.\n\n### Count distinct label values per label, for one metric\n\n```promql\n# How many unique values does each label have on this metric?\ncount by (__name__) (\n  count by (__name__, label_name_here) (\n    http_request_duration_seconds_bucket\n  )\n)\n```\n\nRepeat per label, or use the helper:\n\n```bash\n# Via the Prometheus HTTP API\ncurl -s \"http:\u002F\u002Fprometheus:9090\u002Fapi\u002Fv1\u002Flabels?match[]=http_request_duration_seconds_bucket\" | jq -r '.data[]' | \\\n  while read label; do\n    count=$(curl -s \"http:\u002F\u002Fprometheus:9090\u002Fapi\u002Fv1\u002Flabel\u002F${label}\u002Fvalues?match[]=http_request_duration_seconds_bucket\" | jq '.data | length')\n    echo \"${count}  ${label}\"\n  done | sort -rn | head -20\n```\n\n### Find the top label values for one label\n\n```promql\n# Top 20 path values for http_requests_total\ntopk(20,\n  count by (path) (http_requests_total)\n)\n```\n\nIf you see UUIDs, hashes, timestamps, or numeric IDs in the top values → that label has unbounded values from the source.\n\n### Per-metric series count, grouped\n\n```promql\n# Series-per-instance breakdown — if uneven, one instance is misbehaving\nsum by (job, instance) ({__name__=~\"my_metric.*\"})\n```\n\n---\n\n## Step 4: Recent Change Diff\n\nIf the cardinality fire started recently, the cause is almost always a recent change. Diff what's there now against what was there before.\n\n### List of metrics, current vs. yesterday\n\nVia Grafana Cloud cardinality dashboard, or:\n```promql\n# Current metrics\ngroup by (__name__) ({__name__!=\"\"})\n\n# Compare to last week (offset)\ngroup by (__name__) ({__name__!=\"\"} offset 7d)\n```\n\nDiff externally. A new metric near the top of `seriesCountByMetricName` that wasn't there a week ago → that's your offender.\n\n### Correlate with deploys\n\n```promql\n# Active series correlated with build_info\nprometheus_tsdb_head_series\n# Overlay with:\nchanges(app_build_info[1d])\n```\n\nA vertical step in series count aligned with a deploy is conclusive.\n\n---\n\n## Step 5: Churn Diagnosis\n\nHigh churn means series are being created and abandoned faster than they age out. Symptoms: series count keeps climbing, then drops sharply on Prometheus restart.\n\n### Churn signal\n\n```promql\n# Series created vs. removed per second\nrate(prometheus_tsdb_head_series_created_total[5m])\nrate(prometheus_tsdb_head_series_removed_total[5m])\n\n# Ratio of churned to live\nprometheus_tsdb_head_series_created_total \u002F prometheus_tsdb_head_series\n```\n\nA creation rate that materially exceeds the removal rate, sustained, means cardinality is on a one-way trip up. Common causes:\n\n| Cause | Tell |\n|---|---|\n| Pod rollouts emitting `pod` label | Churn spike aligns with deploy timing; affects pod-discovered scrapes |\n| `version` \u002F `git_sha` \u002F `image_tag` label on every metric | Churn spike on every deploy across many metrics |\n| Ephemeral hostnames in `instance` | Cloud autoscaling event timing |\n| Bug: dynamic label names | Churn climbs forever, never plateaus |\n| Application bug emitting fresh UUIDs as labels | Linear unbounded growth, no deploy correlation |\n\n### Memory impact of churn\n\n```promql\n# A churn-driven head block carries old series until tsdb compaction\nprometheus_tsdb_head_chunks\ngo_memstats_heap_inuse_bytes{job=\"prometheus\"}\n```\n\nRestarting Prometheus drops churned series but is not a fix. The fix is at the source.\n\n---\n\n## Common-Culprit Gallery\n\n### Histogram blowup\n\n**Tell**: `*_bucket` metric at the top of `seriesCountByMetricName`. Multiplier ≈ 14×.\n\n**Fix**:\n1. First, **reduce labels on the histogram at the source** — every label removed saves 14× series. Trim `path`, `method`, or `status_code` in the instrumentation code (don't `labeldrop` them at scrape — that merges distinct histograms and corrupts the buckets). For series already in Grafana Cloud you can't change, aggregate them with Adaptive Metrics.\n2. Then, reduce bucket count if appropriate (custom buckets vs. defaults).\n3. For high-resolution latency tracking, consider **native histograms** (Prometheus 2.40+) — single sparse series replaces the bucket family.\n\n### kube-state-metrics label explosion\n\n**Tell**: `kube_pod_labels` or `kube_pod_annotations` at the top, with `label_*` or `annotation_*` labels driving cardinality.\n\n**Fix**: configure kube-state-metrics with `--metric-labels-allowlist` and `--metric-annotations-allowlist`. By default it emits *all* labels and annotations as series.\n\n```yaml\n# kube-state-metrics flags\n--metric-labels-allowlist=pods=[app,team,version]\n--metric-annotations-allowlist=pods=[checksum\u002Fconfig]\n```\n\n### Path \u002F route blowup from a new endpoint\n\n**Tell**: `http_requests_total` (or framework equivalent) grew 10×+ overnight. `topk(20, count by (path) (http_requests_total))` shows hundreds of `\u002Fusers\u002F123456`-style values.\n\n**Fix**: the real fix is to **template the path in application code** (`\u002Fusers\u002F:id`) — route the user to `prometheus-label-strategy`. For series already in Grafana Cloud, **Adaptive Metrics** can aggregate `path` away correctly — route to `adaptive-metrics`.\n\nDo **not** \"normalize\" `path` with a relabel `replacement` rule — collapsing `\u002Fusers\u002F123`, `\u002Fusers\u002F456`, … into one `\u002Fusers\u002F:id` value at scrape merges distinct series and produces duplicate-sample errors and broken `rate()`. The merge has to happen at the source (templating) or post-ingest (Adaptive Metrics), never at scrape.\n\nIf you must stop a production fire *right now* and templating isn't deployable yet, the only safe scrape-time action is to drop the **entire** offending metric (you lose it completely until the code fix lands — a deliberate trade, not a silent corruption):\n\n```yaml\n# Emergency: drop the whole metric until the source is templated\nmetric_relabel_configs:\n  - source_labels: [__name__]\n    regex: http_requests_total\n    action: drop\n```\n\n### Application emitting a debug metric in prod\n\n**Tell**: A metric you don't recognize in the top 10. Grep the source — often a `_details` or `_per_request` debug metric the developer forgot to gate.\n\n**Fix**: drop entirely at scrape:\n```yaml\nmetric_relabel_configs:\n  - source_labels: [__name__]\n    regex: my_app_request_details\n    action: drop\n```\n\nOpen a ticket against the team to remove it from the code.\n\n### App-emitted labels colliding with target labels\n\n**Tell**: Series count for one job is several × what it should be. Looking at one series, you see both an app-emitted `instance=...` AND the target `instance=...` collided into something weird (Prometheus renames the conflicting one to `exported_instance`).\n\n**Fix**: the right fix is **in the application** — stop emitting `instance`\u002F`node`\u002F`host` from code; they belong to the scrape target. Confirm `honor_labels` is `false` (the default) so the target labels win.\n\nIf you need a scrape-time stopgap, you may remove a label *only* where it **exactly duplicates** a target label — that's the one safe `labeldrop`, because the target label still provides uniqueness. Scope it tightly to the duplicated names and **never include `pod`** (or any other label that is the source of uniqueness):\n\n```yaml\n# Stopgap ONLY for app-emitted duplicates of target labels.\n# Drops the `exported_*` collisions — NOT pod, which makes K8s series unique.\nmetric_relabel_configs:\n  - regex: exported_(instance|node|host)\n    action: labeldrop\n```\n\nThen the target labels from `relabel_configs` apply cleanly. Prefer fixing the app.\n\n### Federation amplifying cardinality\n\n**Tell**: A federated Prometheus or Mimir global view has way more series than expected. Each source has its own `cluster` \u002F `region` label, multiplying.\n\n**Fix**: this is usually expected — federation by design preserves source labels. If the series count is too high, federate only aggregated recording rules, not raw metrics:\n\n```yaml\n- job_name: federate\n  honor_labels: true\n  metrics_path: \u002Ffederate\n  params:\n    'match[]':\n      - '{__name__=~\".*:.*\"}'  # Recording-rule naming convention only\n```\n\n---\n\n## Remediation Decision Tree\n\n```\nCardinality fire confirmed\n│\n├── Need to stop the bleeding NOW (production OOM, ingest 429s)\n│   └── Drop the ENTIRE offending metric via metric_relabel_configs (action: drop on __name__)\n│       (also applies to Alloy\u002FAgent — same syntax)\n│       Do NOT labeldrop a distinguishing label — it breaks the data, see \"The One Rule\".\n│       Then schedule the proper fix.\n│\n├── It's a Grafana Cloud Active Series bill issue, not a perf issue\n│   ├── Cardinality is structural and you can't fix the app\n│   │   └── Route to `adaptive-metrics` skill (post-ingest aggregation rules — the safe way)\n│   └── You want metric-by-metric DPM breakdown\n│       └── Route to `dpm-finder` skill\n│\n├── It's a fixable application bug (unbounded label, debug metric in prod)\n│   ├── Short-term: drop the whole metric at scrape, OR aggregate via Adaptive Metrics\n│   └── Long-term: fix in code; route to `prometheus-label-strategy` for design guidance\n│\n├── It's histogram cardinality\n│   ├── Reduce labels on the underlying histogram AT THE SOURCE (14× win per label)\n│   ├── Reduce bucket count if appropriate\n│   └── Consider native histograms for high-resolution latency\n│\n└── It's churn (deploy-driven)\n    ├── Stop EMITTING `version`\u002F`git_sha`\u002F`instance` from app code (use info-metric for version)\n    ├── Keep `pod` — never drop it; if pod-level series are too costly, use Adaptive Metrics\n    └── Verify K8s SD relabel rules aren't mapping in `uid` or other ephemeral fields\n```\n\n---\n\n## Emergency Drop Patterns (copy-paste ready)\n\nThese are the **safe** scrape-time emergency actions: dropping an *entire* unwanted metric. They do not merge distinct series, so they don't corrupt the data.\n\n> ⚠️ There is intentionally **no `labeldrop` of a distinguishing label** and **no value-normalizing relabel** here. Both merge distinct series and break `rate()`\u002FDPM (see [The One Rule](#before-you-remediate-the-one-rule)). To reduce cardinality *without* dropping the whole metric, fix the source or use **Adaptive Metrics** (route to `adaptive-metrics`). The only safe `labeldrop` is removing a label that *exactly duplicates* a target label (e.g. `exported_instance`) — see [App-emitted labels colliding with target labels](#app-emitted-labels-colliding-with-target-labels).\n\nFor Prometheus `scrape_configs`:\n\n```yaml\nmetric_relabel_configs:\n  # Drop a specific bad metric entirely\n  - source_labels: [__name__]\n    regex: bad_metric_name\n    action: drop\n\n  # Drop a set of debug\u002Ftemporary metrics by name prefix\n  - source_labels: [__name__]\n    regex: debug_.*\n    action: drop\n```\n\nFor Grafana Alloy (`prometheus.relabel` component):\n\n```alloy\nprometheus.relabel \"drop_bad_metric\" {\n  forward_to = [prometheus.remote_write.default.receiver]\n\n  rule {\n    source_labels = [\"__name__\"]\n    regex = \"bad_metric_name\"\n    action = \"drop\"\n  }\n}\n```\n\n**Always test in staging first**, and prefer fixing the source or using Adaptive Metrics over any scrape-time drop.\n\n---\n\n## When to Hand Off\n\n- **\"Now design a label strategy so this doesn't happen again\"** → `prometheus-label-strategy`\n- **\"We need to keep these metrics but reduce cost\"** → `adaptive-metrics`\n- **\"Which metric is the most expensive in DPM terms?\"** → `dpm-finder`\n- **\"Write the PromQL to find this\"** → `promql`\n- **\"Configure this in Alloy\"** → `alloy`\n- **\"Why is my Loki slow?\"** → `loki-label-analyzer` (different system, same family of problems)\n\nThis skill's lane is **diagnosis under pressure**. Prevention, design, and post-ingest cost optimization live elsewhere.\n",{"name":5,"license":15,"description":7},"main","3b63fa056f5de7956766fca020e9c71fdf2b0fab","SKILL\u002Fdevops\u002Ftier2\u002Fgrafana-prometheus-cardinality-troubleshooter",0,"https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault","https:\u002F\u002Fgithub.com\u002Fyhyu13","https:\u002F\u002Fyhyu13.github.io","大丈夫自立于天地之间，岂可郁郁久居于人下\r\nA zealot of AI.","2026-11-14 20:53:07",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add yhyu13\u002FAgentSkillsVault --skill grafana-prometheus-cardinality-troubleshooter",{"tool":39,"command":40},"bunx","bunx skills add yhyu13\u002FAgentSkillsVault --skill grafana-prometheus-cardinality-troubleshooter",{"tool":42,"command":43},"pnpm","pnpm dlx skills add yhyu13\u002FAgentSkillsVault --skill grafana-prometheus-cardinality-troubleshooter","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault\u002Fblob\u002Fmain\u002FSKILL\u002Fdevops\u002Ftier2\u002Fgrafana-prometheus-cardinality-troubleshooter\u002FSKILL.md",true,[],[48,56,63,70,77,84],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7DZJW3GMCBHNCC1J37K73T7","feishu-kdocs-cli","Office cloud CLIs for agents: install, authenticate, verify and troubleshoot Feishu `lark-cli` and Kingsoft\u002FWPS Docs `kdocs-cli`, plus the three China office MCP endpoints (Feishu, WPS SkillHub, Tencent Docs). Use when setting up or re-logging-in 飞书 CLI \u002F 金山文档 CLI, when a command fails with missing scope \u002F PATH \u002F token \u002F device-code errors, when a kdocs or lark command returns 400001 or unknown action, or when wiring 飞书 \u002F 金山文档 \u002F 腾讯文档 MCP into Cindy, Claude or another host. Not a per-command reference: domain commands live in the lark-* Skills and the kdocs Skill.","MIT","https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault\u002Fblob\u002Fmain\u002FSKILL\u002Fdevops\u002Ftier0\u002Ffeishu-kdocs-cli\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7BE0VQF0T7ACMY3W9V27ZYG","vfx-fx","Cinematic and game VFX in Blender including smoke, fire, particles, trails, and Geometry Nodes FX setups via MCP.","https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault\u002Fblob\u002Fmain\u002FSKILL\u002Fgame-dev\u002Ftier2\u002Fvfx-fx\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7BE0Q23SY6QAW24XEADEH0N","uv-workflow","Production UV unwrapping for seam placement, UV packing, texel density, UDIM, lightmap UVs, and modular UV layouts. Use when preparing meshes for texturing and engine export in Blender via MCP.","https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault\u002Fblob\u002Fmain\u002FSKILL\u002Fgame-dev\u002Ftier2\u002Fuv-workflow\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7BE0JAKENVJB4Z0SV3Q7QGR","texture-workflow","Production texture workflow for atlases, baking AO\u002Fcurvature\u002Fnormal\u002Froughness maps, decals, and texture memory optimization. Use for game-ready texture pipelines in Blender via MCP.","https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault\u002Fblob\u002Fmain\u002FSKILL\u002Fgame-dev\u002Ftier2\u002Ftexture-workflow\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7BE0CYB7BDJP7HD5WTS2PJB","sculpting","Blender sculpting for organic and hard surface detail using Dyntopo, multiresolution, brushes, alpha workflow, wrinkles, and damage. Use when high-frequency surface detail is needed before retopology in Blender via MCP.","https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault\u002Fblob\u002Fmain\u002FSKILL\u002Fgame-dev\u002Ftier2\u002Fsculpting\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7BE09TBX9NQ5EBHN4JZ9VXM","scene-assembly","Large scene layout in Blender with collections, linking, overrides, streaming-friendly organization, and set assembly via MCP.","https:\u002F\u002Fgithub.com\u002Fyhyu13\u002FAgentSkillsVault\u002Fblob\u002Fmain\u002FSKILL\u002Fgame-dev\u002Ftier2\u002Fscene-assembly\u002FSKILL.md",[],[]]