mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 22:37:27 -08:00
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),
|
End: timestamp.FromTime(end),
|
||||||
Func: "series", // There is no series function, this token is used for lookups that don't need samples.
|
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
|
if len(matcherSets) > 1 {
|
||||||
for _, mset := range matcherSets {
|
var sets []storage.SeriesSet
|
||||||
// We need to sort this select results to merge (deduplicate) the series sets later.
|
for _, mset := range matcherSets {
|
||||||
s := q.Select(true, hints, mset...)
|
// We need to sort this select results to merge (deduplicate) the series sets later.
|
||||||
sets = append(sets, s)
|
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{}
|
metrics := []labels.Labels{}
|
||||||
for set.Next() {
|
for set.Next() {
|
||||||
metrics = append(metrics, set.At().Labels())
|
metrics = append(metrics, set.At().Labels())
|
||||||
|
|
Loading…
Reference in a new issue