diff --git a/cmd/postgres_exporter/postgres_exporter.go b/cmd/postgres_exporter/postgres_exporter.go index 7ecab7c2..e78c9b87 100644 --- a/cmd/postgres_exporter/postgres_exporter.go +++ b/cmd/postgres_exporter/postgres_exporter.go @@ -708,7 +708,7 @@ func parseFingerprint(url string) (string, error) { pairs := strings.Split(dsn, " ") kv := make(map[string]string, len(pairs)) for _, pair := range pairs { - splitted := strings.Split(pair, "=") + splitted := strings.SplitN(pair, "=", 2) if len(splitted) != 2 { return "", fmt.Errorf("malformed dsn %q", dsn) } diff --git a/cmd/postgres_exporter/postgres_exporter_test.go b/cmd/postgres_exporter/postgres_exporter_test.go index 63cbbd8e..5a0529b6 100644 --- a/cmd/postgres_exporter/postgres_exporter_test.go +++ b/cmd/postgres_exporter/postgres_exporter_test.go @@ -193,6 +193,10 @@ func (s *FunctionalSuite) TestParseFingerprint(c *C) { url: "postgresql://userDsn:passwordDsn@localhost:55432/?sslmode=disabled", fingerprint: "localhost:55432", }, + { + url: "postgresql://userDsn:passwordDsn%3D@localhost:55432/?sslmode=disabled", + fingerprint: "localhost:55432", + }, { url: "port=1234", fingerprint: "localhost:1234",