user17970
user17970

Reputation: 503

How to change Prometheus.yml file in the container

How can I change my / Prometheus/ Prometheus.yml on the container itself I want it to track 1) my appserver - an Node application in a docker container 2) my postgres db 3) my apached and nginx web server

I do know that one has to change the Prometheus.yml file and add targets

Upvotes: 4

Views: 10752

Answers (3)

Tanmay Agarwal
Tanmay Agarwal

Reputation: 111

Open the docker container in interactive mode

docker exec -it <container__id> /bin/sh

Then change the prometheus.yml file which should be placed at /etc/prometheus/prometheus.yml

Now, Stop the container and restart the same container. So, now it will read the updated configuration file.

Upvotes: 0

user10306879
user10306879

Reputation: 41

Generic mechanisms to change docker images are

  1. Mount your configuration file at the desired path.

  2. Create a new image by copying the co fig file in the new Dockerfile. Not recommended if you have to use different configs for different environments/apps

  3. Change the file on the running container if the application (peomerheus in this case) supports it. I know that some of the apps like Kibana do this. Good for debugging, not recommended for production environments.

Upvotes: 4

Sathyajith Bhat
Sathyajith Bhat

Reputation: 21851

It's hard to be precise with an answer given the lack of details but in general, you place your modified prometheus.yml file within the Docker context and modify your Dockerfile to add the instruction

COPY prometheus.yml /path/to/prometheus.yml

Upvotes: 1

Related Questions