prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.81k stars 742 forks source link

Auto-discovery fails block every operation #383

Open akamensky opened 4 years ago

akamensky commented 4 years ago

Details:

Steps:

  1. Run Postgres with default ident authentication
  2. Prepare queries file locally same as the one in this repo
  3. Run exporter locally (as supposed with ident) with auto discovery enabled as postgres user (superuser) and connecting to unix socket using DATA_SOURCE_NAME="user=postgres host=/var/run/postgresql database=postgres sslmode=disable" and using local queries

Expected outcome:

Auto-discovery finds all databases and can connect to them, every refresh of metrics page from exporter is "instantaneous"

Actual outcome:

Startup always delayed by num_of_dbs * 6 seconds. Every refresh of metrics page takes exactly num_of_dbs * 6 seconds. exporter is FAILING to connect to all discovered DBs.

NOTE:

I already gave it unrestricted superuser access and it is still FAILING to connect to DBs? No, I am not going to use md5 auth over TCP sockets, I want to use ident running locally from restricted user, however appears ident even when using superuser is not working properly.

frittentheke commented 4 years ago

@akamensky Is this the same issue as https://github.com/wrouesnel/postgres_exporter/issues/293 ?

akamensky commented 4 years ago

@frittentheke not exactly, this is about the timing it needs to fail. 6 seconds per each existing database is a bit too much, we are trying to pull data every 10 seconds, while EVERY request takes about 3 minutes because of number of different databases this instance contains.

sholz commented 4 years ago

I am facing similar issues. With auto-discovery enabled everything is very slow.

I am seeing log messages which I think are indicating that prometheus closes connections already while results are still being calculated:

http: multiple response.WriteHeader calls

Also liveness issues on k8s are occurring when auto-discovery is enabled.

Without auto-discovery everything works fine but without that multiple databases are not supported.