'I modified Prometheus YML. How can I make the modification take effect without restarting docker compose?

docker-compose.yml:

version: '3.2'
services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
    - 9090:9090
    command:
    - --config.file=/etc/prometheus/prometheus.yml 
    - --web.enable-lifecycle
    volumes:
    - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro

prometheus.yml

scrape_configs:
- job_name: cadvisor
  scrape_interval: 5s
  static_configs:
  - targets:
    - cadvisor:8080
- job_name: node
  scrape_interval: 5s
  static_configs:
  - targets: ['127.0.0.1:9100']


Solution 1:[1]

You can restart the prometheus service:

docker-compose restart prometheus

You have the --web-enable-lifecycle flag set correctly on the container so you should be able to POST to the Prometheus reload endpoint:

curl --request POST http://localhost:9090/-/reload

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DazWilkin