Clamp functions should ignore native histograms
@ -14,6 +14,7 @@
* [BUGFIX] PromQL: Fix stddev+stdvar aggregations to always ignore native histograms. #14941
* [BUGFIX] PromQL: Fix stddev+stdvar aggregations to treat Infinity consistently. #14941
* [BUGFIX] OTLP receiver: Preserve colons when generating metric names in suffix adding mode (this mode is always enabled, unless one uses Prometheus as a library). #15251
* [BUGFIX] Clamp functions: Ignore any points with native histograms. #15169
## 3.0.0-beta.1 / 2024-10-09
@ -474,6 +474,10 @@ func funcClamp(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper
return enh.Out, nil
}
for _, el := range vec {
if el.H != nil {
// Process only float samples.
continue
if !enh.enableDelayedNameRemoval {
el.Metric = el.Metric.DropMetricName()
@ -491,6 +495,10 @@ func funcClampMax(vals []parser.Value, args parser.Expressions, enh *EvalNodeHel
vec := vals[0].(Vector)
maxVal := vals[1].(Vector)[0].F
@ -508,6 +516,10 @@ func funcClampMin(vals []parser.Value, args parser.Expressions, enh *EvalNodeHel
minVal := vals[1].(Vector)[0].F
@ -452,6 +452,21 @@ eval instant at 0m clamp(test_clamp, NaN, 0)
eval instant at 0m clamp(test_clamp, 5, -5)
clear
load 1m
mixed_metric {{schema:0 sum:5 count:4 buckets:[1 2 1]}} 1 2 3 {{schema:0 sum:5 count:4 buckets:[1 2 1]}} {{schema:0 sum:8 count:6 buckets:[1 4 1]}}
# clamp ignores any histograms
eval range from 0 to 5m step 1m clamp(mixed_metric, 2, 5)
{} _ 2 2 3
eval range from 0 to 5m step 1m clamp_min(mixed_metric, 2)
eval range from 0 to 5m step 1m clamp_max(mixed_metric, 2)
{} _ 1 2 2
# Test cases for sgn.
load 5m