mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 07:23:02 +00:00
Merge pull request #8731 from yeya24/update
Improve grouping label match logic
This commit is contained in:
commit
e36e5fa833
@ -2191,16 +2191,7 @@ func (ev *evaluator) aggregation(op parser.ItemType, grouping []string, without
|
|||||||
lb.Del(labels.MetricName)
|
lb.Del(labels.MetricName)
|
||||||
m = lb.Labels()
|
m = lb.Labels()
|
||||||
} else {
|
} else {
|
||||||
m = make(labels.Labels, 0, len(grouping))
|
m = metric.WithLabels(grouping...)
|
||||||
for _, l := range metric {
|
|
||||||
for _, n := range grouping {
|
|
||||||
if l.Name == n {
|
|
||||||
m = append(m, l)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort.Sort(m)
|
|
||||||
}
|
}
|
||||||
result[groupingKey] = &groupedAggregation{
|
result[groupingKey] = &groupedAggregation{
|
||||||
labels: m,
|
labels: m,
|
||||||
@ -2339,7 +2330,7 @@ func (ev *evaluator) aggregation(op parser.ItemType, grouping []string, without
|
|||||||
continue // Bypass default append.
|
continue // Bypass default append.
|
||||||
|
|
||||||
case parser.BOTTOMK:
|
case parser.BOTTOMK:
|
||||||
// The heap keeps the lowest value on top, so reverse it.
|
// The heap keeps the highest value on top, so reverse it.
|
||||||
sort.Sort(sort.Reverse(aggr.reverseHeap))
|
sort.Sort(sort.Reverse(aggr.reverseHeap))
|
||||||
for _, v := range aggr.reverseHeap {
|
for _, v := range aggr.reverseHeap {
|
||||||
enh.Out = append(enh.Out, Sample{
|
enh.Out = append(enh.Out, Sample{
|
||||||
|
Loading…
Reference in New Issue
Block a user