Skip to content
This repository was archived by the owner on May 25, 2024. It is now read-only.

Commit 5441d34

Browse files
committed
print full URL but mask password
1 parent 875374c commit 5441d34

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

postgres_exporter.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,11 +997,12 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
997997

998998
db, err := getDB(e.dsn)
999999
if err != nil {
1000-
loggableDatabaseSource := "could not parse DATA_SOURCE_NAME"
1000+
loggableDsn := "could not parse DATA_SOURCE_NAME"
10011001
if pDsn, pErr := url.Parse(e.dsn); pErr != nil {
1002-
loggableDatabaseSource = pDsn.Host
1002+
pDsn.User = url.UserPassword(pDsn.User.Username(), "xxx")
1003+
loggableDsn = pDsn.String()
10031004
}
1004-
log.Infof("Error opening connection to database (%s): %s", loggableDatabaseSource, err)
1005+
log.Infof("Error opening connection to database (%s): %s", loggableDsn, err)
10051006
e.error.Set(1)
10061007
return
10071008
}

0 commit comments

Comments
 (0)