Pcornel
Observability · Prometheus

Service Discovery in Prometheus

Cheat sheet · https://pcornel.dk/topic.php?topic=6216

Back to the Topic

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 topic
  • curl -s localhost:9090/-/ready — Prometheus ready
  • curl -s 'localhost:9090/api/v1/query?query=up' — scrape targets up/down
  • promtool 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

Confirmation

Confirm action

Continue?