From 631d93b8d97b073173dcdd4752a4e18c7bb0efa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Bence=20Nagy?= Date: Tue, 4 Jun 2019 17:31:27 +0200 Subject: [PATCH] Add ability to set Prometheus url with custom path without trailing '/' --- pkg/metrics/client.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/metrics/client.go b/pkg/metrics/client.go index 60541aff..6f6615df 100644 --- a/pkg/metrics/client.go +++ b/pkg/metrics/client.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "net/http" "net/url" + "path" "strconv" "strings" "text/template" @@ -84,6 +85,7 @@ func (p *PrometheusClient) RunQuery(query string) (float64, error) { if err != nil { return 0, err } + u.Path = path.Join(p.url.Path, u.Path) u = p.url.ResolveReference(u) @@ -150,6 +152,7 @@ func (p *PrometheusClient) IsOnline() (bool, error) { if err != nil { return false, err } + u.Path = path.Join(p.url.Path, u.Path) u = p.url.ResolveReference(u)