diff --git a/pkg/servergroup/servergroup.go b/pkg/servergroup/servergroup.go index 946e535c0..bde81400c 100644 --- a/pkg/servergroup/servergroup.go +++ b/pkg/servergroup/servergroup.go @@ -200,6 +200,13 @@ func (s *ServerGroup) loadTargetGroupMap(targetGroupMap map[string][]*targetgrou var apiClient promclient.API apiClient = &promclient.PromAPIV1{v1.NewAPI(client)} + // If debug logging is enabled, wrap the client with a debugAPI client + // Since these are called in the reverse order of what we add, we want + // to make sure that this is the first wrap of the client + if logrus.GetLevel() >= logrus.DebugLevel { + apiClient = &promclient.DebugAPI{apiClient, u.String()} + } + if s.Cfg.RemoteRead { u.Path = path.Join(u.Path, s.Cfg.RemoteReadPath) cfg := &remote.ClientConfig{ @@ -255,13 +262,6 @@ func (s *ServerGroup) loadTargetGroupMap(targetGroupMap map[string][]*targetgrou } - // If debug logging is enabled, wrap the client with a debugAPI client - // Since these are called in the reverse order of what we add, we want - // to make sure that this is the last wrap of the client - if logrus.GetLevel() >= logrus.DebugLevel { - apiClient = &promclient.DebugAPI{apiClient, u.String()} - } - // Add LabelFilter if configured if s.Cfg.LabelFilterConfig != nil { apiClient, err = promclient.NewLabelFilterClient(ctx, apiClient, s.Cfg.LabelFilterConfig)