mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 22:49:40 -08:00
Merge pull request #1290 from prometheus/max-nan
Handle NaN for min/max.
This commit is contained in:
commit
a50b699708
|
@ -1084,11 +1084,11 @@ func (ev *evaluator) aggregation(op itemType, grouping model.LabelNames, keepExt
|
||||||
groupedResult.value += sample.Value
|
groupedResult.value += sample.Value
|
||||||
groupedResult.groupCount++
|
groupedResult.groupCount++
|
||||||
case itemMax:
|
case itemMax:
|
||||||
if groupedResult.value < sample.Value {
|
if groupedResult.value < sample.Value || math.IsNaN(float64(groupedResult.value)) {
|
||||||
groupedResult.value = sample.Value
|
groupedResult.value = sample.Value
|
||||||
}
|
}
|
||||||
case itemMin:
|
case itemMin:
|
||||||
if groupedResult.value > sample.Value {
|
if groupedResult.value > sample.Value || math.IsNaN(float64(groupedResult.value)) {
|
||||||
groupedResult.value = sample.Value
|
groupedResult.value = sample.Value
|
||||||
}
|
}
|
||||||
case itemCount:
|
case itemCount:
|
||||||
|
|
22
promql/testdata/operators.test
vendored
Normal file
22
promql/testdata/operators.test
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Tests for min/max.
|
||||||
|
clear
|
||||||
|
load 5m
|
||||||
|
http_requests{job="api-server", instance="0", group="production"} 1
|
||||||
|
http_requests{job="api-server", instance="1", group="production"} 2
|
||||||
|
http_requests{job="api-server", instance="0", group="canary"} NaN
|
||||||
|
http_requests{job="api-server", instance="1", group="canary"} 3
|
||||||
|
http_requests{job="api-server", instance="2", group="canary"} 4
|
||||||
|
|
||||||
|
eval instant at 0m max(http_requests)
|
||||||
|
{} 4
|
||||||
|
|
||||||
|
eval instant at 0m min(http_requests)
|
||||||
|
{} 1
|
||||||
|
|
||||||
|
eval instant at 0m max by (group) (http_requests)
|
||||||
|
{group="production"} 2
|
||||||
|
{group="canary"} 4
|
||||||
|
|
||||||
|
eval instant at 0m min by (group) (http_requests)
|
||||||
|
{group="production"} 1
|
||||||
|
{group="canary"} 3
|
Loading…
Reference in a new issue