prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.72k stars 725 forks source link

Documentation should explain how docker interacts with the database #92

Open lukeshaughnessy opened 7 years ago

lukeshaughnessy commented 7 years ago

Steps to Reproduce:

  1. Verify database user and password:
    
    psql --host 127.0.0.1 --port 5432 --username postgres_exporter postgres
    Password for user postgres_exporter: 
    psql (9.5.7)
    SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
    Type "help" for help.

postgres=>

2. Docker run with:

docker run -e DATA_SOURCE_NAME="postgresql://postgres_exporter:password@127.0.0.1:5432/postgres?sslmode=disable" -p 9187:9187 wrouesnel/postgres_exporter

3. Result:

level=info msg="Error opening connection to database (could not parse DATA_SOURCE_NAME): dial tcp 127.0.0.1:5432: getsockopt: connection refused" source="postgres_exporter.go:959"

manics commented 7 years ago

127.0.0.1 as seen by the postgres_exporter Docker container refers to itself, try using the IP of the system hosting the DB?

lukeshaughnessy commented 7 years ago

Thanks, that was the correct answer. Maybe a note in the docs to specify host ip in the docker run command?

baryluk commented 5 years ago

Maybe just use --net=host.