Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Prometheus & Monitoring Difficulty: Advanced ClaudeChatGPTCursor

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

More Prometheus & Monitoring prompts & error guides

Browse every Prometheus & Monitoring prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.