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...) }