From 3df51bf0256658f04de7048317d96caf008f26ff Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Fri, 28 Oct 2022 16:52:36 +0200 Subject: [PATCH] Prometheus: Do not drop errors in streaming parser (#57698) (#57835) - Fixes #57692 - and also takes care of #42776 when using the streaming parser, not an ideal fix for #42776 but makes explore work better I think. https://github.com/grafana/grafana/issues/57365 might be a better longer term solution (cherry picked from commit 6126f56ef0a0428ab3021c5a3368c2911000654f) Co-authored-by: Kyle Brandt --- pkg/tsdb/prometheus/querydata/request.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pkg/tsdb/prometheus/querydata/request.go b/pkg/tsdb/prometheus/querydata/request.go index 0269b05c380..2e52aaab2bd 100644 --- a/pkg/tsdb/prometheus/querydata/request.go +++ b/pkg/tsdb/prometheus/querydata/request.go @@ -2,6 +2,7 @@ package querydata import ( "context" + "fmt" "net/http" "regexp" "time" @@ -110,18 +111,26 @@ func (s *QueryData) fetch(ctx context.Context, client *client.Client, q *models. Error: nil, } + if q.InstantQuery { + res, err := s.instantQuery(traceCtx, client, q, headers) + if err != nil { + return nil, err + } + response.Error = res.Error + response.Frames = res.Frames + } + if q.RangeQuery { res, err := s.rangeQuery(traceCtx, client, q, headers) if err != nil { return nil, err } - response.Frames = res.Frames - } - - if q.InstantQuery { - res, err := s.instantQuery(traceCtx, client, q, headers) - if err != nil { - return nil, err + if res.Error != nil { + if response.Error == nil { + response.Error = res.Error + } else { + response.Error = fmt.Errorf("%v %w", response.Error, res.Error) // lovely + } } response.Frames = append(response.Frames, res.Frames...) }