Loki: Add X-Query-Tags header for logs sample and data sample (#62333)

This commit is contained in:
Ivana Huckova
2023-01-27 16:41:40 +01:00
committed by GitHub
parent 9453bec819
commit d0e95f8c95
8 changed files with 115 additions and 38 deletions
+30 -10
View File
@@ -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,
})
}