Answers: <p><a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#docker_sd_config" rel="nofollow noreferrer">https://prometheus.io/docs/prometheus/latest/configuration/configuration/#docker_sd_config</a></p>
  <h1>List of Docker service discovery configurations.</h1>
  <p>docker_sd_configs:
  [ - &lt;docker_sd_config&gt; ... ]</p>
  <p>As per doc :
  This SD discovers &quot;containers&quot; and will create a target for each network IP and port the container is configured to expose.</p>
  <p>So it would start scraping as soon there a new container starts listening</p>
  
Answers: CC BY-SA 4.0
Answers: 2024-04-10T15:53:02.330Z
Answers: 2024-04-10T15:53:02.330Z
Answers: tintin
Body: <p>I have an application running in a Docker stack, and it dynamically scales its instances based on demand. This application exports its own metrics, and I want Prometheus to scrape these metrics in real-time without manually updating its configuration every time the number of instances changes.</p>
  <p>How can I achieve dynamic service discovery for Docker containers in my Prometheus configuration? Specifically, I'm looking for a way to configure Prometheus to automatically discover and scrape the metrics of all instances of my Dockerized application without manual intervention.</p>
  <p>I've been experimenting with different approaches to achieve dynamic service discovery for Docker containers in Prometheus. I tried using the Prometheus Pushgateway, but unfortunately, it's too unstable for my needs, resulting in the loss of over half of my metrics. I also looked into the Swarm service discovery feature, but it seems to provide metrics at the service level rather than from individual containers. However, my requirement is to collect metrics directly from the containers.</p>
  
Tags: <prometheus><docker-swarm>
Title: Dynamic service discovery for Docker containers in Prometheus configuration
UserDisplayName: user3270532
ThreadText: # Dynamic service discovery for Docker containers in Prometheus configuration
  
  (Asked by: username_0 on 2024-04-09)
  
  I have an application running in a Docker stack, and it dynamically scales its instances based on demand. This application exports its own metrics, and I want Prometheus to scrape these metrics in real-time without manually updating its configuration every time the number of instances changes.
  
  How can I achieve dynamic service discovery for Docker containers in my Prometheus configuration? Specifically, I'm looking for a way to configure Prometheus to automatically discover and scrape the metrics of all instances of my Dockerized application without manual intervention.
  
  I've been experimenting with different approaches to achieve dynamic service discovery for Docker containers in Prometheus. I tried using the Prometheus Pushgateway, but unfortunately, it's too unstable for my needs, resulting in the loss of over half of my metrics. I also looked into the Swarm service discovery feature, but it seems to provide metrics at the service level rather than from individual containers. However, my requirement is to collect metrics directly from the containers.
  
  **Tags:** prometheus, docker-swarm
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-04-10. Score: 0
  
  <https://prometheus.io/docs/prometheus/latest/configuration/configuration/#docker_sd_config>
  
  # List of Docker service discovery configurations.
  
  docker\_sd\_configs:
  [ - <docker\_sd\_config> ... ]
  
  As per doc :
  This SD discovers "containers" and will create a target for each network IP and port the container is configured to expose.
  
  So it would start scraping as soon there a new container starts listening
  
  
  ---
  
  