Closed oBaqazi closed 6 years ago
@oBaqazi You'll need to edit docker-compose.yml and add the prometheus.yml file in (2) places inside, a total of (4) lines. Take a look at the configs: section near the top that defines the Docker config metadata, and then look for the configs: section of the prometheus: service definition, you'll see other config label and file examples there to copy to have swarm propagate your file into a container when it's brought up using the 'docker config ls' mechanism.
Also, a volume mounted at ./local_dir:/prometheus/conf would replace everything in that directory, probably not what you want. Either use a Docker config to get your local single file into your container at a specified location, or put your files into ./local_dir and map them into the container in a different place (e.g. /prometheus/local_config) and then modify the docker-compose.yml prometheus: command: - '--config.file=/etc/prometheus/prometheus.yml' to match your new config file.
Also see https://github.com/swarmstack/swarmstack which has the exact config: lines to cut-n-paste to bring a local prometheus.yml file into your container.
Thank you sir , it works
Hi I am trying to edit prometheus targets in /prometheus/conf/prometheus .yml but the prometheus container did not take the modification. I also try to make volume from /prometheus/conf/prometheus .yml to etc/prometheus/prometheus .yml but it didn't wotk .
1 - prometheus file in /prometheus/conf/prometheus .yml
global: scrape_interval: 15s evaluation_interval: 15s
external_labels: monitor: 'promswarm'
rule_files:
alerting: alertmanagers:
scrape_configs:
job_name: 'prometheus' static_configs:
job_name: 'dockerd-exporter' dns_sd_configs:
job_name: 'cadvisor' dns_sd_configs:
job_name: 'node-exporter' dns_sd_configs:
job_name: 'centos_node_exporter' static_configs:
2 - prometheus file in the prometheus container /etc/prometheus/prometheus.yml global: scrape_interval: 15s evaluation_interval: 15s
external_labels: monitor: 'promswarm'
rule_files:
alerting: alertmanagers:
scrape_configs:
job_name: 'prometheus' static_configs:
job_name: 'dockerd-exporter' dns_sd_configs:
job_name: 'cadvisor' dns_sd_configs:
job_name: 'node-exporter' dns_sd_configs: