mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 10:32:42 +08:00
Loki: Add X-Query-Tags header for logs sample and data sample (#62333)
This commit is contained in:
@ -85,8 +85,11 @@ func makeDataRequest(ctx context.Context, lokiDsUrl string, query lokiQuery) (*h
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if query.VolumeQuery {
|
||||
req.Header.Set("X-Query-Tags", "Source=logvolhist")
|
||||
if query.SupportingQueryType != SupportingQueryNone {
|
||||
value := getSupportingQueryHeaderValue(req, query.SupportingQueryType)
|
||||
if value != "" {
|
||||
req.Header.Set("X-Query-Tags", "Source="+value)
|
||||
}
|
||||
}
|
||||
|
||||
return req, nil
|
||||
@ -223,3 +226,18 @@ func (api *LokiAPI) RawQuery(ctx context.Context, resourcePath string) (RawLokiR
|
||||
|
||||
return encodedBytes, nil
|
||||
}
|
||||
|
||||
func getSupportingQueryHeaderValue(req *http.Request, supportingQueryType SupportingQueryType) string {
|
||||
value := ""
|
||||
switch supportingQueryType {
|
||||
case SupportingQueryLogsVolume:
|
||||
value = "logvolhist"
|
||||
case SupportingQueryLogsSample:
|
||||
value = "logsample"
|
||||
case SupportingQueryDataSample:
|
||||
value = "datasample"
|
||||
default: //ignore
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
Reference in New Issue
Block a user