diff --git a/internal/alertmanager/models.go b/internal/alertmanager/models.go index 1f727c9e0..512361fbd 100644 --- a/internal/alertmanager/models.go +++ b/internal/alertmanager/models.go @@ -4,13 +4,11 @@ import ( "fmt" "net/http" "net/url" - "path" "sort" "strings" "sync" "time" - "github.com/prymitive/karma/internal/config" "github.com/prymitive/karma/internal/filters" "github.com/prymitive/karma/internal/mapper" "github.com/prymitive/karma/internal/models" @@ -183,11 +181,7 @@ func (am *Alertmanager) pullSilences(version string) error { // InternalURI is the URI of this Alertmanager that will be used for all request made by the UI func (am *Alertmanager) InternalURI() string { if am.ProxyRequests { - sub := fmt.Sprintf("/proxy/alertmanager/%s", am.Name) - if strings.HasPrefix(config.Config.Listen.Prefix, "/") { - return path.Join(config.Config.Listen.Prefix, sub) - } - return path.Join("/"+config.Config.Listen.Prefix, sub) + return fmt.Sprintf("./proxy/alertmanager/%s", am.Name) } // strip all user/pass information, fetch() doesn't support it anyway diff --git a/internal/alertmanager/models_test.go b/internal/alertmanager/models_test.go index f6a118a37..0fbb12c36 100644 --- a/internal/alertmanager/models_test.go +++ b/internal/alertmanager/models_test.go @@ -33,13 +33,13 @@ var uriTests = []uriTest{ { rawURI: "http://alertmanager.example.com", proxy: true, - internalURI: "/proxy/alertmanager/test", + internalURI: "./proxy/alertmanager/test", publicURI: "http://alertmanager.example.com", }, { rawURI: "http://alertmanager.example.com/foo", proxy: true, - internalURI: "/proxy/alertmanager/test", + internalURI: "./proxy/alertmanager/test", publicURI: "http://alertmanager.example.com/foo", }, { @@ -57,21 +57,21 @@ var uriTests = []uriTest{ { rawURI: "http://user:pass@alertmanager.example.com", proxy: true, - internalURI: "/proxy/alertmanager/test", + internalURI: "./proxy/alertmanager/test", publicURI: "http://user:pass@alertmanager.example.com", }, { rawURI: "http://user:pass@alertmanager.example.com", extURI: "http://am.example.com", proxy: true, - internalURI: "/proxy/alertmanager/test", + internalURI: "./proxy/alertmanager/test", publicURI: "http://am.example.com", }, { rawURI: "http://alertmanager.example.com", extURI: "http://am.example.com", proxy: true, - internalURI: "/proxy/alertmanager/test", + internalURI: "./proxy/alertmanager/test", publicURI: "http://am.example.com", }, { @@ -134,27 +134,27 @@ func TestAlertmanagerInternalURI(t *testing.T) { { prefix: "/", proxy: true, - uri: "/proxy/alertmanager/default", + uri: "./proxy/alertmanager/default", }, { prefix: "/root", proxy: true, - uri: "/root/proxy/alertmanager/default", + uri: "./proxy/alertmanager/default", }, { prefix: "/root/", proxy: true, - uri: "/root/proxy/alertmanager/default", + uri: "./proxy/alertmanager/default", }, { prefix: "root", proxy: true, - uri: "/root/proxy/alertmanager/default", + uri: "./proxy/alertmanager/default", }, { prefix: "root/", proxy: true, - uri: "/root/proxy/alertmanager/default", + uri: "./proxy/alertmanager/default", }, }