From 6b4d93b8ecf95a6df0a97598e5c1a9cf2596e5f8 Mon Sep 17 00:00:00 2001 From: Adam Simpson Date: Mon, 28 Jul 2025 10:42:32 -0400 Subject: [PATCH] querier: check for headers to force expr parsing (#108701) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gábor Farkas --- pkg/services/query/query.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/services/query/query.go b/pkg/services/query/query.go index d3f05438e45..e2c3f68043d 100644 --- a/pkg/services/query/query.go +++ b/pkg/services/query/query.go @@ -25,6 +25,7 @@ import ( "github.com/grafana/grafana/pkg/services/contexthandler" "github.com/grafana/grafana/pkg/services/datasources" "github.com/grafana/grafana/pkg/services/mtdsclient" + "github.com/grafana/grafana/pkg/services/ngalert/models" "github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext" "github.com/grafana/grafana/pkg/services/validations" "github.com/grafana/grafana/pkg/setting" @@ -97,6 +98,12 @@ func (s *ServiceImpl) Run(ctx context.Context) error { // QueryData processes queries and returns query responses. It handles queries to single or mixed datasources, as well as expressions. func (s *ServiceImpl) QueryData(ctx context.Context, user identity.Requester, skipDSCache bool, reqDTO dtos.MetricRequest) (*backend.QueryDataResponse, error) { + fromAlert := false + for header, val := range s.headers { + if header == models.FromAlertHeaderName && val == "true" { + fromAlert = true + } + } // Parse the request into parsed queries grouped by datasource uid parsedReq, err := s.parseMetricRequest(ctx, user, skipDSCache, reqDTO) if err != nil { @@ -104,7 +111,7 @@ func (s *ServiceImpl) QueryData(ctx context.Context, user identity.Requester, sk } // If there are expressions, handle them and return - if parsedReq.hasExpression { + if parsedReq.hasExpression || fromAlert { return s.handleExpressions(ctx, user, parsedReq) } // If there is only one datasource, query it and return