Loki: Add X-Query-Tags header for logs sample and data sample (#62333)
This commit is contained in:
@@ -82,6 +82,21 @@ func parseDirection(jsonValue string) (Direction, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func parseSupportingQueryType(jsonValue string) (SupportingQueryType, error) {
|
||||
switch jsonValue {
|
||||
case "logsVolume":
|
||||
return SupportingQueryLogsVolume, nil
|
||||
case "logsSample":
|
||||
return SupportingQueryLogsSample, nil
|
||||
case "dataSample":
|
||||
return SupportingQueryDataSample, nil
|
||||
case "":
|
||||
return SupportingQueryNone, nil
|
||||
default:
|
||||
return SupportingQueryNone, fmt.Errorf("invalid supportingQueryType: %s", jsonValue)
|
||||
}
|
||||
}
|
||||
|
||||
func parseQuery(queryContext *backend.QueryDataRequest) ([]*lokiQuery, error) {
|
||||
qs := []*lokiQuery{}
|
||||
for _, query := range queryContext.Queries {
|
||||
@@ -115,17 +130,22 @@ func parseQuery(queryContext *backend.QueryDataRequest) ([]*lokiQuery, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
supportingQueryType, err := parseSupportingQueryType(model.SupportingQueryType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
qs = append(qs, &lokiQuery{
|
||||
Expr: expr,
|
||||
QueryType: queryType,
|
||||
Direction: direction,
|
||||
Step: step,
|
||||
MaxLines: model.MaxLines,
|
||||
LegendFormat: model.LegendFormat,
|
||||
Start: start,
|
||||
End: end,
|
||||
RefID: query.RefID,
|
||||
VolumeQuery: model.VolumeQuery,
|
||||
Expr: expr,
|
||||
QueryType: queryType,
|
||||
Direction: direction,
|
||||
Step: step,
|
||||
MaxLines: model.MaxLines,
|
||||
LegendFormat: model.LegendFormat,
|
||||
Start: start,
|
||||
End: end,
|
||||
RefID: query.RefID,
|
||||
SupportingQueryType: supportingQueryType,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user