Loki: Set Query limits context header (#114112)
* feat(lokiQueryLimitsContext): send full query range & expr on initial split requests
This commit is contained in:
@@ -96,6 +96,8 @@ func makeDataRequest(ctx context.Context, lokiDsUrl string, query lokiQuery) (*h
|
||||
return nil, backend.DownstreamError(fmt.Errorf("failed to create request: %w", err))
|
||||
}
|
||||
|
||||
addQueryLimitsHeader(query, req)
|
||||
|
||||
if query.SupportingQueryType != SupportingQueryNone {
|
||||
value := getSupportingQueryHeaderValue(query.SupportingQueryType)
|
||||
if value != "" {
|
||||
@@ -108,6 +110,15 @@ func makeDataRequest(ctx context.Context, lokiDsUrl string, query lokiQuery) (*h
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func addQueryLimitsHeader(query lokiQuery, req *http.Request) {
|
||||
if len(query.LimitsContext.Expr) > 0 {
|
||||
queryLimitStr, err := json.Marshal(query.LimitsContext)
|
||||
if err == nil {
|
||||
req.Header.Set("X-Loki-Query-Limits-Context", string(queryLimitStr))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type lokiResponseError struct {
|
||||
Message string `json:"message"`
|
||||
TraceID string `json:"traceID,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user