From 2de496bf4bb9c4c71513ef4e7852b5be5c167538 Mon Sep 17 00:00:00 2001 From: Joshua Hesketh Date: Wed, 27 Nov 2024 11:03:41 +1100 Subject: [PATCH] Update note on ph values --- .../operators/functions/histograms.go | 2 ++ .../testdata/ours/classic_histograms.test | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/streamingpromql/operators/functions/histograms.go b/pkg/streamingpromql/operators/functions/histograms.go index a91ab38583..8800caaf9b 100644 --- a/pkg/streamingpromql/operators/functions/histograms.go +++ b/pkg/streamingpromql/operators/functions/histograms.go @@ -336,6 +336,8 @@ func (h *HistogramFunctionOverInstantVector) computeOutputSeriesForGroup(g *buck if math.IsNaN(ph) || ph < 0 || ph > 1 { // Even when ph is invalid we still return a series as BucketQuantile will return +/-Inf. // So don't skip/continue the series, just emit a warning. + // Additionally, even if a point isn't returned, an annotation is emitted if ph is invalid + // at any step. h.annotations.Add(annotations.NewInvalidQuantileWarning(ph, h.phArg.ExpressionPosition())) } diff --git a/pkg/streamingpromql/testdata/ours/classic_histograms.test b/pkg/streamingpromql/testdata/ours/classic_histograms.test index b0091decfc..b5e938d542 100644 --- a/pkg/streamingpromql/testdata/ours/classic_histograms.test +++ b/pkg/streamingpromql/testdata/ours/classic_histograms.test @@ -62,6 +62,21 @@ eval_warn range from 0m to 24m step 6m histogram_quantile(scalar(ph), series) clear +# Test for invalid ph value where no points +load 6m + series{le="0"} 0 _ 0 + series{le="2"} 1 _ 1 + series{le="4"} 2 _ 2 + series{le="6"} 3 _ 3 + series{le="+Inf"} 3 _ 3 + ph 0.5 NaN 0.9 + +# Both engines output a warning even though there is no point where ph is also invalid. +eval_warn range from 0m to 12m step 6m histogram_quantile(scalar(ph), series) + {} 3 _ 5.4 + +clear + # Test various mixed metric scenarios load 6m series{host="a", le="0.1"} 2 _ 1 {{schema:0 sum:5 count:4 buckets:[2 2 2]}}