diff --git a/pkg/store/proxy.go b/pkg/store/proxy.go index 040859cc368..666f130eceb 100644 --- a/pkg/store/proxy.go +++ b/pkg/store/proxy.go @@ -338,13 +338,12 @@ func (s *ProxyStore) Series(originalRequest *storepb.SeriesRequest, srv storepb. continue } - matches, matched := s.tsdbSelector.MatchLabelSets(st.LabelSets()...) + matches, extraMatchers := s.tsdbSelector.MatchLabelSets(st.LabelSets()...) if !matches { continue } - if len(matched) < len(st.LabelSets()) { - storeLabelSets = append(storeLabelSets, matched...) - } + storeLabelSets = append(storeLabelSets, extraMatchers...) + stores = append(stores, st) } if len(stores) == 0 { diff --git a/pkg/store/proxy_test.go b/pkg/store/proxy_test.go index 8a128796d72..97ebfdb55d6 100644 --- a/pkg/store/proxy_test.go +++ b/pkg/store/proxy_test.go @@ -1688,7 +1688,7 @@ type rawSeries struct { } func seriesEquals(t *testing.T, expected []rawSeries, got []storepb.Series) { - testutil.Equals(t, len(expected), len(got), "got unexpected number of series: \n %v", got) + testutil.Equals(t, len(expected), len(got), "got unexpected number of series: \n want: %v \n got: %v", expected, got) ret := make([]rawSeries, len(got)) for i, s := range got { diff --git a/pkg/store/tsdb_selector.go b/pkg/store/tsdb_selector.go index 5ab1832a639..c9beef6e777 100644 --- a/pkg/store/tsdb_selector.go +++ b/pkg/store/tsdb_selector.go @@ -33,10 +33,11 @@ func NewTSDBSelector(relabelConfig []*relabel.Config) *TSDBSelector { } // MatchLabelSets returns true if the given label sets match the TSDBSelector. -// It also returns those label sets that were matched. +// As a second parameter, it returns the matched label sets if they are a subset of the given input. +// Otherwise the second return value is nil. func (sr *TSDBSelector) MatchLabelSets(labelSets ...labels.Labels) (bool, []labels.Labels) { if sr.relabelConfig == nil || len(labelSets) == 0 { - return true, labelSets + return true, nil } matchedLabelSets := sr.runRelabelRules(labelSets) return len(matchedLabelSets) > 0, matchedLabelSets