From 9ea5ceffdb36a1ffb6387c6a7cc636205fd9cf41 Mon Sep 17 00:00:00 2001 From: "hao.peng" Date: Tue, 15 Oct 2024 11:36:15 +0800 Subject: [PATCH] app/vmselect/prometheus: remove stale NaN for range vector query --- app/vmselect/prometheus/prometheus.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index 91ac0c2fa..d608d4494 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -22,6 +22,7 @@ import ( "github.com/VictoriaMetrics/VictoriaMetrics/app/vmselect/searchutils" "github.com/VictoriaMetrics/VictoriaMetrics/lib/bufferedwriter" "github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil" + "github.com/VictoriaMetrics/VictoriaMetrics/lib/decimal" "github.com/VictoriaMetrics/VictoriaMetrics/lib/encoding" "github.com/VictoriaMetrics/VictoriaMetrics/lib/fasttime" "github.com/VictoriaMetrics/VictoriaMetrics/lib/flagutil" @@ -402,8 +403,13 @@ func exportHandler(qt *querytracer.Tracer, w http.ResponseWriter, cp *commonPara } xb := exportBlockPool.Get().(*exportBlock) xb.mn = &rs.MetricName - xb.timestamps = rs.Timestamps - xb.values = rs.Values + for i, v := range rs.Values { + if decimal.IsStaleNaN(v) { + continue + } + xb.values = append(xb.values, v) + xb.timestamps = append(xb.timestamps, rs.Timestamps[i]) + } if err := writeLineFunc(xb, workerID); err != nil { return err }