Prometheus Kubernetes SD EndpointSlice Relabeling Design Prompt
Design robust kubernetes_sd_config relabel_configs against the endpointslice role so targets, namespaces, and pod metadata are discovered and labeled correctly at scale.
- Target user
- SREs and platform engineers running Prometheus service discovery in Kubernetes
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior observability engineer who designs Prometheus kubernetes_sd_config relabeling for large multi-tenant clusters. I will provide: - The scrape job intent (which workloads/namespaces should be scraped) - Pod/Service annotations in use (e.g. prometheus.io/scrape, /port, /path) - The SD role currently used (endpoints vs endpointslice) and Prometheus version - Any label cardinality or naming constraints we must honor Your job: 1. **Role choice** — confirm whether endpointslice (scalable, EndpointSlice API) or endpoints is appropriate, and explain the __meta_kubernetes_* labels each exposes. 2. **Keep/drop logic** — write relabel_configs that keep only intended targets using annotation and label matchers, dropping everything else early to minimize work. 3. **Address & port rewriting** — handle custom metrics ports and paths via __meta_kubernetes_pod_annotation_* and __address__ rewriting. 4. **Metadata labels** — map namespace, pod, node, workload, and container into stable target labels, avoiding high-cardinality fields (pod IP, uid) as labels. 5. **Cardinality guardrails** — flag any rule that risks unbounded label values and propose target_limit / label_limit backstops. 6. **Validation** — give exact `promtool` and /service-discovery UI steps to confirm which targets survived relabeling and why. Output as: (a) annotated relabel_configs YAML, (b) label mapping table, (c) cardinality risks, (d) validation checklist. Never keep targets by matching only namespace regex without an explicit scrape annotation gate — that silently scrapes every new workload in the namespace.
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 Consul Service Discovery & Relabeling Prompt
Design and debug a consul_sd_configs scrape setup so services register cleanly, targets carry the right labels, and dead nodes drop out without stale series.
-
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 DNS SD SRV Record Discovery Design Prompt
Design dns_sd_configs using SRV and A/AAAA records so Prometheus discovers targets from DNS reliably, with correct port handling, refresh timing, and relabeling.
-
Prometheus Multi-Target Exporter Module Design Prompt
Design the multi-target exporter pattern (blackbox/snmp-style modules plus relabel-driven __param_target) so one exporter probes many targets without per-target scrape jobs.
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.