From 7f8930bccfc86c3fc41eb11af2b356ac109b8339 Mon Sep 17 00:00:00 2001 From: wenhuwang Date: Thu, 8 Aug 2024 13:18:51 +0800 Subject: [PATCH 1/2] metrics: fix the issue of special characters being escaped in passwords Signed-off-by: wenhuwang --- metrics/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metrics/metrics.go b/metrics/metrics.go index 09468b5..b2e5e54 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -140,7 +140,7 @@ func (ms *Metrics) createCollector(config ExporterConfig) (prometheus.Collector, switch config.Type { case model.ApplicationTypePostgres: - userPass := url.UserPassword(config.Credentials.Username, config.Credentials.Password) + userPass := fmt.Sprintf("%s:%s", config.Credentials.Username, config.Credentials.Password) query := url.Values{} query.Set("connect_timeout", "1") query.Set("statement_timeout", strconv.Itoa(int(timeout.Milliseconds()))) @@ -157,7 +157,7 @@ func (ms *Metrics) createCollector(config ExporterConfig) (prometheus.Collector, return collector, func() { _ = collector.Close() }, nil case model.ApplicationTypeMysql: - userPass := url.UserPassword(config.Credentials.Username, config.Credentials.Password) + userPass := fmt.Sprintf("%s:%s", config.Credentials.Username, config.Credentials.Password) query := url.Values{} query.Set("timeout", fmt.Sprintf("%dms", timeout.Milliseconds())) tls := config.Params["tls"] From c95844ea0e4e738147c7ce440f90cd5a123acd08 Mon Sep 17 00:00:00 2001 From: wenhuwang Date: Mon, 19 Aug 2024 09:34:54 +0800 Subject: [PATCH 2/2] metrics: revert changes for Postgres Signed-off-by: wenhuwang --- metrics/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics/metrics.go b/metrics/metrics.go index b2e5e54..9a16d69 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -140,7 +140,7 @@ func (ms *Metrics) createCollector(config ExporterConfig) (prometheus.Collector, switch config.Type { case model.ApplicationTypePostgres: - userPass := fmt.Sprintf("%s:%s", config.Credentials.Username, config.Credentials.Password) + userPass := url.UserPassword(config.Credentials.Username, config.Credentials.Password) query := url.Values{} query.Set("connect_timeout", "1") query.Set("statement_timeout", strconv.Itoa(int(timeout.Milliseconds())))