prometheus.yml. That works for small, stable fleets, but in cloud-native or containerized environments where instances are frequently created and terminated, manually maintaining this list becomes error-prone and unscalable. Service discovery automates this process so Prometheus always scrapes the right endpoints.
Static scrape configuration example (from prometheus.yml):

prometheus.yml. Prometheus ships with multiple built-in discovery integrations that work with cloud providers, orchestration systems, DNS, and external files (via file_sd), enabling reliable target discovery across different infrastructures.
Static configuration is a basic form of service discovery: you tell Prometheus which endpoints to scrape. For dynamic environments, Prometheus provides more flexible discovery mechanisms that update targets automatically.
file_sd (where an external process writes target lists that Prometheus reads).

This lesson includes practical examples and configuration patterns for several of these discovery mechanisms, plus an explanation of relabeling and target filtering so you can shape discovered targets to match your scrape and metric collection needs.
Links and references:
- Prometheus Service Discovery official docs
- Prometheus relabeling documentation
- Prometheus file_sd documentation