Prometheus sample_limit Target Protection Prompt
Design per-target sample_limit guardrails that protect a Prometheus server from a single misbehaving exporter blowing up cardinality, without dropping legitimate metrics from healthy targets.
- Target user
- SRE or platform team operating a shared Prometheus that must survive noisy multi-tenant exporters
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior observability engineer who runs shared Prometheus clusters and has watched one runaway exporter take down ingestion for an entire team. I will provide: - The scrape_config(s) in question (job_name, current sample_limit if any, scrape_interval) - Approximate series counts per target (or how to estimate them) - The blast radius I care about (single shared server, sharded fleet, agent + remote_write) - My tolerance for dropping samples vs. dropping whole scrapes Your job: 1. **Explain the mechanism** — clarify that `sample_limit` fails the *entire scrape* if the post-relabel series count exceeds the limit (it does not silently truncate), how it differs from `label_limit`/`label_value_length_limit`, and how `scrape_samples_scraped` and `scrape_samples_post_metric_relabeling` expose actual counts. 2. **Size the limit** — derive a per-job limit from observed `scrape_samples_post_metric_relabeling` plus growth headroom, and explain why setting it too tight causes intermittent full-scrape failures during legitimate spikes. 3. **Layer the defenses** — combine `sample_limit` with `metric_relabel_configs` drops for known-noisy series so the limit is a backstop, not the primary cardinality control. 4. **Detect breaches** — write alerting rules on `scrape_samples_scraped` approaching the limit and on `up == 0` correlated with `scrape_samples_post_metric_relabeling` to distinguish a limit-triggered failure from a network failure. 5. **Operational rollout** — recommend a safe rollout (observe-only baseline first, then enforce) and a per-team override pattern using scrape-config templating. Output as: (a) the corrected scrape_config YAML with sample_limit/label_limit and comments showing the math, (b) two PromQL alert expressions (approaching-limit and limit-exceeded), (c) a one-paragraph rollout plan. Do not set an aggressive sample_limit on a production job without first observing real series counts under peak load.
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 target_limit & label_limit Guardrails Prompt
Configure target_limit, label_limit, label_name_length_limit, and label_value_length_limit to protect a Prometheus server from service-discovery explosions and abusive label sets in a multi-tenant environment.
-
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.
-
Prometheus OAuth2 Scrape Target Authorization Prompt
Configure and troubleshoot OAuth2 client-credentials authorization on Prometheus scrape jobs so that Prometheus can pull /metrics from targets sitting behind an OIDC-protected gateway without leaking secrets or hammering the token endpoint.
-
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.
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.