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.
- Target user
- Platform engineer wiring Prometheus to a bespoke service registry or CMDB via http_sd
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior observability engineer who has integrated Prometheus with half a dozen in-house service registries through http_sd.
I will provide:
- My current http_sd_config block (url, refresh_interval, auth)
- A sample JSON response from my discovery endpoint
- The symptom (no targets appearing, stale targets lingering, missing labels, auth failures, or refresh too slow/fast)
- Any meta-labels I need to map into final target labels
Your job:
1. **Validate the response contract** — confirm the endpoint returns the exact JSON shape Prometheus expects: a list of `{ "targets": [...], "labels": { "__meta_...": "..." } }` objects, served as `application/json`, and flag any schema deviations in my sample.
2. **Get discovery working** — produce a correct http_sd_config with `url`, `refresh_interval`, and the right `authorization`/`tls_config`, explaining how Prometheus polls (HTTP GET) and how `refresh_interval` controls target churn latency vs. registry load.
3. **Map meta-labels** — write `relabel_configs` that promote `__meta_*` labels (and the `__address__`) into stable target labels like `job`, `instance`, `env`, including drops for targets that should not be scraped.
4. **Handle failures gracefully** — explain what happens when the endpoint is down or returns malformed JSON (Prometheus keeps the last good target set), and how to alert on `prometheus_sd_http_failures_total` and discovery staleness.
5. **Tune refresh** — recommend a `refresh_interval` balancing how fast new targets must be picked up against registry load, and contrast with file_sd or DNS-SD if those fit better.
Output as: (a) any corrections needed to the endpoint's JSON, (b) the complete corrected http_sd_config + relabel_configs YAML, (c) one alerting expression on SD failures, (d) the most likely cause of the reported symptom.
Do not embed long-lived credentials inline — reference a file or environment-injected secret in the config.
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 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 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.