Loki: Apply scopes to expression if feature toggle is enabled. (#95917)

Signed-off-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
This commit is contained in:
Carl Bergquist
2024-11-11 12:53:24 +01:00
committed by GitHub
co-authored by Kyle Brandt
parent 8148f0c3bb
commit c7b6822a5e
9 changed files with 79 additions and 10 deletions
+9 -1
View File
@@ -125,7 +125,7 @@ func parseSupportingQueryType(jsonPointerValue *string) SupportingQueryType {
}
}
func parseQuery(queryContext *backend.QueryDataRequest) ([]*lokiQuery, error) {
func parseQuery(queryContext *backend.QueryDataRequest, logqlScopesEnabled bool) ([]*lokiQuery, error) {
qs := []*lokiQuery{}
for _, query := range queryContext.Queries {
model, err := parseQueryModel(query.JSON)
@@ -171,6 +171,13 @@ func parseQuery(queryContext *backend.QueryDataRequest) ([]*lokiQuery, error) {
legendFormat = *model.LegendFormat
}
if logqlScopesEnabled {
rewrittenExpr, err := ApplyScopes(expr, model.Scopes)
if err == nil {
expr = rewrittenExpr
}
}
supportingQueryType := parseSupportingQueryType(model.SupportingQueryType)
qs = append(qs, &lokiQuery{
@@ -184,6 +191,7 @@ func parseQuery(queryContext *backend.QueryDataRequest) ([]*lokiQuery, error) {
End: end,
RefID: query.RefID,
SupportingQueryType: supportingQueryType,
Scopes: model.Scopes,
})
}