Observability · Prometheus
Service Discovery in Prometheus
Cheat sheet · https://pcornel.dk/topic.php?topic=6216
Answer
Prometheus service discovery finds scrape targets dynamically (Kubernetes, Consul, EC2, file_sd, DNS) and relabelling turns discovered metadata into target labels or filters.
Remember
Check Service Discovery page: discovered labels before relabel vs target labels after. A keep/drop rule may be filtering your target.
First checks
curl -s localhost:9090/api/v1/targets?state=dropped— first check for this topiccurl -s localhost:9090/-/ready— Prometheus readycurl -s 'localhost:9090/api/v1/query?query=up'— scrape targets up/downpromtool check config prometheus.yml— config valid
Verify in this order
SD source → discovered targets → relabel → scrape targets
Where it usually breaks
A keep rule on a missing annotation drops every target.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6216