mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Nonexistent labels in BY-clauses shouldn't propagate to result.
This fixes bug 2. of https://github.com/prometheus/prometheus/issues/374 Change-Id: Ia4a13153616bafce5bf10597966b071434422d09
This commit is contained in:
parent
c342ad33a0
commit
0378c2ca1f
|
@ -398,7 +398,9 @@ func (node *VectorAggregation) Eval(timestamp clientmodel.Timestamp, view *viewA
|
||||||
} else {
|
} else {
|
||||||
m[clientmodel.MetricNameLabel] = sample.Metric[clientmodel.MetricNameLabel]
|
m[clientmodel.MetricNameLabel] = sample.Metric[clientmodel.MetricNameLabel]
|
||||||
for _, l := range node.groupBy {
|
for _, l := range node.groupBy {
|
||||||
m[l] = sample.Metric[l]
|
if v, ok := sample.Metric[l]; ok {
|
||||||
|
m[l] = v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result[groupingKey] = &groupedAggregation{
|
result[groupingKey] = &groupedAggregation{
|
||||||
|
|
|
@ -139,6 +139,15 @@ func TestExpressions(t *testing.T) {
|
||||||
},
|
},
|
||||||
fullRanges: 0,
|
fullRanges: 0,
|
||||||
intervalRanges: 8,
|
intervalRanges: 8,
|
||||||
|
}, {
|
||||||
|
// Non-existent labels mentioned in BY-clauses shouldn't propagate to output.
|
||||||
|
expr: `SUM(http_requests) BY (job, nonexistent)`,
|
||||||
|
output: []string{
|
||||||
|
`http_requests{job="api-server"} => 1000 @[%v]`,
|
||||||
|
`http_requests{job="app-server"} => 2600 @[%v]`,
|
||||||
|
},
|
||||||
|
fullRanges: 0,
|
||||||
|
intervalRanges: 8,
|
||||||
}, {
|
}, {
|
||||||
expr: `
|
expr: `
|
||||||
// Test comment.
|
// Test comment.
|
||||||
|
|
Loading…
Reference in a new issue