What did you do?
If the exporter is configured to use Unix domain socket connections over URL postgres:///dbname?host=/run/postgresql, autodiscovery tries to resolve the additional databases as hosts.
A workaround is to use key=value key=value connection strings, but this is incompatible with Grafana alloy, which insists DSNs must be valid URLs.
The culprit is here:
|
dsnURI.Path = databaseName |
Golang URL structure tries to fix this path when hostname is not empty, but it does not try so hard when there is no hostname.
I tried reporting to upstream golang, but they decided that it is on the user to prepend a slash (golang/go#79532).
Context: grafana/alloy#4624 (comment)
What did you expect to see?
Autodiscovery of my databases.
What did you see instead? Under which circumstances?
Exporter trying to connect to hosts named as my databases.
Environment
? I think N/A
-
PostgreSQL version:
-
Logs:
Oct 17 19:34:53 bareostest.hebler.lab alloy[8703]: ts=2025-10-17T17:34:53.07021794Z level=error msg="error encountered scraping DSN" component_path=/ component_id=prometheus.exporter.postgres.default err="Error opening connection to database (postgresql://bareos?host=/run/postgresql&sslmode=disable): dial tcp: lookup bareos on 192.168.122.1:53: no such host"
What did you do?
If the exporter is configured to use Unix domain socket connections over URL
postgres:///dbname?host=/run/postgresql, autodiscovery tries to resolve the additional databases as hosts.A workaround is to use
key=value key=valueconnection strings, but this is incompatible with Grafana alloy, which insists DSNs must be valid URLs.The culprit is here:
postgres_exporter/exporter/datasource.go
Line 77 in ca51864
Golang URL structure tries to fix this path when hostname is not empty, but it does not try so hard when there is no hostname.
I tried reporting to upstream golang, but they decided that it is on the user to prepend a slash (golang/go#79532).
Context: grafana/alloy#4624 (comment)
What did you expect to see?
Autodiscovery of my databases.
What did you see instead? Under which circumstances?
Exporter trying to connect to hosts named as my databases.
Environment
System information:
postgres_exporter version:
<bundled in latest alloy, issue still present on master>
postgres_exporter flags:
? I think N/A
PostgreSQL version:
Logs: