GetSeries should Select sorted results only if more than one matcher is requested
@@ -768,15 +768,21 @@ func (api *API) series(r *http.Request) (result apiFuncResult) {
End: timestamp.FromTime(end),
Func: "series", // There is no series function, this token is used for lookups that don't need samples.
}
+ var set storage.SeriesSet
+ if len(matcherSets) > 1 {
var sets []storage.SeriesSet
for _, mset := range matcherSets {
// We need to sort this select results to merge (deduplicate) the series sets later.
s := q.Select(true, hints, mset...)
sets = append(sets, s)
}
+ set = storage.NewMergeSeriesSet(sets, storage.ChainedSeriesMerge)
+ } else {
+ // At this point at least one match exists.
+ set = q.Select(false, hints, matcherSets[0]...)
+ }
- set := storage.NewMergeSeriesSet(sets, storage.ChainedSeriesMerge)
metrics := []labels.Labels{}
for set.Next() {
metrics = append(metrics, set.At().Labels())
