diff --git a/pkg/storage/prometheus.go b/pkg/storage/prometheus.go index 4afd6cf..3989885 100644 --- a/pkg/storage/prometheus.go +++ b/pkg/storage/prometheus.go @@ -37,17 +37,6 @@ func Prometheus(prometheusAPIURL string, customHeaders map[string]string) Driver } func (promCli *prometheusStorageClient) init() { - if viper.IsSet("maia.proxy") { - proxyURL, err := url.Parse(viper.GetString("maia.proxy")) - if err != nil { - panic(fmt.Errorf("could not set proxy: %s .\n%s", proxyURL, err.Error())) - } else { - promCli.httpClient = &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}} - return - } - } - promCli.httpClient = &http.Client{} - // if federateURL is configured, this will direct /federate requests to another host URL if viper.IsSet("maia.federate_url") { parsedURL, err := url.Parse(viper.GetString("maia.federate_url")) @@ -58,6 +47,16 @@ func (promCli *prometheusStorageClient) init() { } else { promCli.federateURL = promCli.url } + + if viper.IsSet("maia.proxy") { + proxyURL, err := url.Parse(viper.GetString("maia.proxy")) + if err != nil { + panic(fmt.Errorf("could not set proxy: %s .\n%s", proxyURL, err.Error())) + } + promCli.httpClient = &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}} + return + } + promCli.httpClient = &http.Client{} } func (promCli *prometheusStorageClient) Query(query, time, timeout, acceptContentType string) (*http.Response, error) {