From db57fbc5d619c6e43ad9c795419a56115941f788 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 15 Sep 2023 20:23:59 +0300 Subject: [PATCH] app/vmselect: return +Inf as null in graphite render api (#5009) Signed-off-by: Konstantin Kulikov --- app/vmselect/graphite/render_response.qtpl | 2 +- app/vmselect/graphite/render_response.qtpl.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/vmselect/graphite/render_response.qtpl b/app/vmselect/graphite/render_response.qtpl index 308a378ad..2ea588e64 100644 --- a/app/vmselect/graphite/render_response.qtpl +++ b/app/vmselect/graphite/render_response.qtpl @@ -47,7 +47,7 @@ See https://graphite.readthedocs.io/en/stable/render_api.html#json {% code timestamps := s.Timestamps %} {% for i, v := range s.Values %} [ - {% if math.IsNaN(v) %}null{% else %}{%f= v %}{% endif %}, + {% if math.IsNaN(v) || math.IsInf(v, 0) %}null{% else %}{%f= v %}{% endif %}, {%dl= timestamps[i]/1e3 %} ] {% if i+1 < len(timestamps) %},{% endif %} diff --git a/app/vmselect/graphite/render_response.qtpl.go b/app/vmselect/graphite/render_response.qtpl.go index 213403fb1..77a87998e 100644 --- a/app/vmselect/graphite/render_response.qtpl.go +++ b/app/vmselect/graphite/render_response.qtpl.go @@ -148,7 +148,7 @@ func streamrenderSeriesJSON(qw422016 *qt422016.Writer, s *series) { //line app/vmselect/graphite/render_response.qtpl:48 qw422016.N().S(`[`) //line app/vmselect/graphite/render_response.qtpl:50 - if math.IsNaN(v) { + if math.IsNaN(v) || math.IsInf(v, 0) { //line app/vmselect/graphite/render_response.qtpl:50 qw422016.N().S(`null`) //line app/vmselect/graphite/render_response.qtpl:50