From 2daae9eba80b007720338362506a6faf6f10e167 Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Fri, 5 Nov 2021 18:00:48 +0100 Subject: [PATCH] Prometheus: Fix showing of errors (#41356) * Prometheus: Fix showing of errors * Refactor and add comment --- pkg/tsdb/prometheus/time_series_query.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/tsdb/prometheus/time_series_query.go b/pkg/tsdb/prometheus/time_series_query.go index b663218f34e..1fbbb47b8d1 100644 --- a/pkg/tsdb/prometheus/time_series_query.go +++ b/pkg/tsdb/prometheus/time_series_query.go @@ -71,9 +71,9 @@ func (s *Service) executeTimeSeriesQuery(ctx context.Context, req *backend.Query if err != nil { plog.Error("Range query failed", "query", query.Expr, "err", err) result.Responses[query.RefId] = backend.DataResponse{Error: err} - } else { - response[RangeQueryType] = rangeResponse + continue } + response[RangeQueryType] = rangeResponse } if query.InstantQuery { @@ -81,16 +81,17 @@ func (s *Service) executeTimeSeriesQuery(ctx context.Context, req *backend.Query if err != nil { plog.Error("Instant query failed", "query", query.Expr, "err", err) result.Responses[query.RefId] = backend.DataResponse{Error: err} - } else { - response[InstantQueryType] = instantResponse + continue } + response[InstantQueryType] = instantResponse } + // This is a special case + // If exemplar query returns error, we want to only log it and continue with other results processing if query.ExemplarQuery { exemplarResponse, err := client.QueryExemplars(ctx, query.Expr, timeRange.Start, timeRange.End) if err != nil { plog.Error("Exemplar query failed", "query", query.Expr, "err", err) - result.Responses[query.RefId] = backend.DataResponse{Error: err} } else { response[ExemplarQueryType] = exemplarResponse }