Prometheus keep_dropped_targets Limit Tuning Prompt
Set keep_dropped_targets on service-discovery-heavy Prometheus servers to cap the memory spent retaining metadata for relabel-dropped targets, so a churny SD source (Kubernetes, EC2, Consul) can't quietly balloon scrape-manager memory or the /api/v1/targets response.
- Target user
- SRE running Prometheus against high-churn service discovery where thousands of targets are dropped by relabeling
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior observability engineer who has debugged Prometheus servers where the scrape manager and the /api/v1/targets endpoint ate gigabytes because relabel-dropped targets were retained forever, and you know how `keep_dropped_targets` bounds that. I will provide: - My service discovery sources and rough scale (e.g. Kubernetes with N pods, EC2 with M instances) and how many get dropped by `relabel_configs` - Symptoms (rising process memory, slow or huge /api/v1/targets and /targets UI, big `prometheus_sd_kubernetes_*` or dropped-target counts) - Whether I rely on inspecting dropped targets for debugging relabeling - Prometheus version and whether limits are set globally or per-job Your job: 1. **Explain the mechanism.** Clarify that Prometheus keeps metadata for targets dropped by relabeling so they show up under "dropped targets" for debugging, and that on high-churn SD this set grows large. `keep_dropped_targets` caps how many dropped targets are retained per scrape config (0 = unlimited); it does NOT change which targets are scraped, only how many dropped ones are remembered. 2. **Quantify the cost.** Show which metrics reveal the problem — `prometheus_target_scrape_pools_total`, the dropped-target counts, and process RSS (`process_resident_memory_bytes`) — and how a large `dropReason`/dropped set correlates with memory and a slow `/api/v1/targets?state=dropped`. 3. **Choose a value.** Recommend setting `keep_dropped_targets` globally (under `global:`) as a safe fleet default and overriding per job where I genuinely need to inspect drops, with reasoning for a starting number given my scale. 4. **Preserve debuggability.** Explain the trade-off: too low a cap and I lose visibility into what relabeling dropped (harder to debug a "why isn't my target scraped" question); give the workaround of temporarily raising it or reading `promtool` relabel test output instead. 5. **Combine with other guardrails.** Relate it to `target_limit` (caps *scraped* targets and fails the scrape pool) and to reducing drops at the source with better `relabel_configs`/SD filtering (e.g. Kubernetes `selectors`) so fewer targets are discovered-then-dropped in the first place. Output as: (a) the global + per-job YAML with comments, (b) the PromQL/curl to measure dropped-target pressure and memory, (c) a one-paragraph note on the debuggability trade-off and how to inspect drops when the cap is low. Do not set keep_dropped_targets to a tiny value on a server where teams debug scrape targeting through the dropped-targets UI without warning them, and prefer filtering at the SD layer over silently discarding drop metadata.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Prometheus http_sd Dynamic Target Discovery Prompt
Design and debug an http_sd_config integration so Prometheus pulls its scrape targets from a custom HTTP discovery endpoint, with correct refresh, labeling, and failure handling.
-
Prometheus Scrape Config Relabel Target Pruning Design Prompt
Design relabel_configs in a scrape job to keep/drop the right targets from service discovery, rewrite the instance/job labels, and prune noisy discovered endpoints before they ever scrape.
-
Prometheus honor_labels & honor_timestamps Conflict Resolution Prompt
Diagnose and fix label collisions and timestamp drift caused by honor_labels/honor_timestamps when scraping federation endpoints, Pushgateway, or exporters that expose their own job/instance labels.
-
Prometheus Scrape Config & Service Discovery Prompt
Configure Prometheus scrape targets — kubernetes_sd, ec2_sd, file_sd, consul_sd, relabeling, scrape interval tuning.
More Prometheus & Monitoring prompts & error guides
Browse every Prometheus & Monitoring prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.