Home > Back-end >  How to add docker container as data source in grafana?
How to add docker container as data source in grafana?

Time:11-30

I have a Postgres Database which was deployed as a Docker container in Linux server. How can i add this as a data source in grafana? I tried finding the docker host IP address using sudo ip addr show docker0 and got the result as 172.17.255.255. I added this URL in Host name field. And added the port number as 5432. But still, grafana is unable to fetch the data from DB. How can i do this?

CodePudding user response:

If your database has its port closed you should use a docker networks but if the port is exposed you should try to use your host ip address instead of the docker gateway address

CodePudding user response:

  1. With docker ps, check if your Postgres container expose the port, eg.
CONTAINER ID   IMAGE            COMMAND                  CREATED          STATUS          PORTS                                       NAMES
e25459aa0ed6   postgres:10.17   "docker-entrypoint.s…"   12 seconds ago   Up 11 seconds   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   jovial_merkle
  1. If not, stop the service, then restart it exposing the port with docker run -d -p 5432:5432 ....
  2. Check if there is any firewall rule that allow to access the port from outside the server.
  3. Now you can reach you DB using the server IP
  • Related