Search code examples
postgresqldockerprometheus

Can't connect postgres_exporter to postgresql database


I can't connect postgres_exporter to postgresql database. I am getting

time="2019-04-29T15:37:46Z" level=info msg="Established new database connection to \"localhost:5432\"." source="postgres_exporter.go:767"
time="2019-04-29T15:37:46Z" level=error msg="Error opening connection to database (postgresql://postgres:PASSWORD_REMOVED@localhost:5432/postgres?sslmode=disable): pq: unknown authentication response: 10" source="postgres_exporter.go:1260"
time="2019-04-29T15:37:46Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1360"

Port is ok, password too. When I am trying to run it as

# Start an example database
docker run --net=host -it --rm -e POSTGRES_PASSWORD=password postgres
# Connect to it
docker run --net=host -e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" wrouesnel/postgres_exporter

it works perfectly but there is already postgresql running instance so I can't create new one.


Solution

  • Looks like you're using SCRAM authentication in your database but the postgres_exporter doesn't support it yet.

    You can either wait for this issue to be resolved, build the exporter yourself with an updated lib/pq package to enable SCRAM support or resort to using md5 authentication.