Loki: Set Query limits context header (#114112)
* feat(lokiQueryLimitsContext): send full query range & expr on initial split requests
This commit is contained in:
@@ -156,6 +156,8 @@ func parseQuery(queryContext *backend.QueryDataRequest, logqlScopesEnabled bool)
|
||||
|
||||
expr := interpolateVariables(model.Expr, interval, timeRange, queryType, step)
|
||||
|
||||
limitsConfig := generateLimitsConfig(model, interval, timeRange, queryType, step)
|
||||
|
||||
direction, err := parseDirection(model.Direction)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -192,8 +194,21 @@ func parseQuery(queryContext *backend.QueryDataRequest, logqlScopesEnabled bool)
|
||||
RefID: query.RefID,
|
||||
SupportingQueryType: supportingQueryType,
|
||||
Scopes: model.Scopes,
|
||||
LimitsContext: limitsConfig,
|
||||
})
|
||||
}
|
||||
|
||||
return qs, nil
|
||||
}
|
||||
|
||||
func generateLimitsConfig(model *QueryJSONModel, interval time.Duration, timeRange time.Duration, queryType QueryType, step time.Duration) LimitsContext {
|
||||
var limitsConfig LimitsContext
|
||||
// Only supply limits context config if we have expression, and from and to
|
||||
if model.LimitsContext != nil && model.LimitsContext.Expr != "" && model.LimitsContext.From > 0 && model.LimitsContext.To > 0 {
|
||||
// If a limits expression was provided, interpolate it and parse the time range
|
||||
limitsConfig.Expr = interpolateVariables(model.LimitsContext.Expr, interval, timeRange, queryType, step)
|
||||
limitsConfig.From = time.UnixMilli(model.LimitsContext.From)
|
||||
limitsConfig.To = time.UnixMilli(model.LimitsContext.To)
|
||||
}
|
||||
return limitsConfig
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user