Skip to content

Commit c3fbc44

Browse files
authored
PMM-9541 Fix database discover when using socket (#118)
When discovering databases and using local socket connection add trailing "/" to the database name to omit using it as a host for the connection.
1 parent aec5cf0 commit c3fbc44

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmd/postgres_exporter/datasource.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ func (e *Exporter) discoverDatabaseDSNs() []string {
7575
}
7676

7777
if dsnURI != nil {
78-
dsnURI.Path = databaseName
78+
if dsnURI.Host == "" && strings.HasPrefix(dsnURI.Path, "/") {
79+
dsnURI.Path = "/" + databaseName
80+
} else {
81+
dsnURI.Path = databaseName
82+
}
7983
dsn = dsnURI.String()
8084
} else {
8185
// replacing one dbname with another is complicated.

0 commit comments

Comments
 (0)