postgres_exporter icon indicating copy to clipboard operation
postgres_exporter copied to clipboard

DATA_SOURCE_URI did not support unix_socket?

Open skilyazhnev opened this issue 4 years ago • 3 comments
trafficstars

hi!

I ran into a problem when using the DATA_SOURCE_URI variable - there is no way to pass unix socket as host. At the same time, the --auto-discover-databases mode does not work when using DATA_SOURCE_NAME in principle.

i tried various variants of DATA_SOURCE_URI:

  • export DATA_SOURCE_URI="/one?host=/tmp"
  • export DATA_SOURCE_URI="/one?sslmode=disable&host=/tmp"
  • export DATA_SOURCE_URI="%2Ftmp:5432/one?sslmode=disable"

At best, this line parsed but did not use a local socket. INFO[0000] Established new database connection to "localhost:5432". source="postgres_exporter.go:878" INFO[0000] Semantic Version Changed on "localhost:5432": 0.0.0 -> 12.6.0 source="postgres_exporter.go:1405"

Is there a universal way to write a connection string with using any keys? postgres_exporter version: 0.8.0

skilyazhnev avatar Mar 31 '21 08:03 skilyazhnev

I don't use /tmp, but I am using /var/run/postgresql and this is working for me:

DATA_SOURCE_URI="prometheus@:5432/postgres?host=/var/run/postgresql"

For some reasons, the port is required.

saifulmuhajir avatar May 18 '21 08:05 saifulmuhajir

For some reasons, the port is required.

I think the port is needed because the socket file contains the port. e.g. .s.PGSQL.nnnn -> .s.PGSQL.5432

Reamer avatar Sep 21 '21 07:09 Reamer

Since the README marks DATA_SOURCE_NAME as legacy the examples in it should be adjusted as well.

hashworks avatar Feb 06 '24 15:02 hashworks