Grafana Cloud - Setup for postgres in docker within docker-compose stack?

I’ve installed the grafana agent on my ubuntu server and recording the node metrics correctly.
I’ve also installed the relevant docker connection and have metrics being recorded from my docker-compose managed containers.

One of the containers on this server is a postgre database. I’m going around in circles trying to work out how I can monitor this using grafana cloud.

I’ve found some quite old instructions which suggests installing postgres-exporter as a container in my compose stack and connecting to the database from here to export metrics/logs.

I’m now not quite sure though how to get this outputting either a) Directly to grafana cloud api b) to the local grafana agent to use the inbuilt postgres collection to cloud.

I’ve thought about just exposing a postgres port from the docker network to the host but I don’t overly want to expose ports if I dont need to. I also guess I could run the grafana agent within a container to be able to connect to the postgres db on the same network but unsure on the config for that and if it would have any clashes with the local agent on the host.

Solved this.

Installed postgres_exporter container within my docker-compose stack. Exporter config set to point to my postgres instance. I exposed the logging port for the exporter and had to then update my cloud agent with the exporter config.

The exporter complained in its logs about no default config file but you don’t need one for this.

I then installed a postgres dashboard and data flowed through nicely.

1 Like