GetSeries should Select sorted results only if more than one matcher is requested (#11313)
Signed-off-by: Alan Protasio <approtas@amazon.com> Signed-off-by: Alan Protasio <approtas@amazon.com>
This commit is contained in:
parent
35d6813963
commit
f1a3dbbb6b
|
@ -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
|
||||
|
||||
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)
|
||||
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())
|
||||
|
|
Loading…
Reference in New Issue