stefanprodan / swarmprom

Docker Swarm instrumentation with Prometheus, Grafana, cAdvisor, Node Exporter and Alert Manager
MIT License
1.87k stars 736 forks source link

modify the prometheus.yml file to add new job #76

Closed oBaqazi closed 6 years ago

oBaqazi commented 6 years ago

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:

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:

mh720 commented 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.

mh720 commented 6 years ago

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.

oBaqazi commented 6 years ago

Thank you sir , it works