Loki: alerting: handle variables like __interval and __range (#42126)

This commit is contained in:
Gábor Farkas
2021-11-24 16:56:53 +01:00
committed by GitHub
parent ccd162f806
commit 24d4c8a9d1
4 changed files with 129 additions and 58 deletions

View File

@@ -182,38 +182,6 @@ func formatLegend(metric model.Metric, query *lokiQuery) string {
return string(result)
}
func parseQuery(dsInfo *datasourceInfo, queryContext *backend.QueryDataRequest) ([]*lokiQuery, error) {
qs := []*lokiQuery{}
for _, query := range queryContext.Queries {
model := &ResponseModel{}
err := json.Unmarshal(query.JSON, model)
if err != nil {
return nil, err
}
start := query.TimeRange.From
end := query.TimeRange.To
var resolution int64 = 1
if model.Resolution >= 1 && model.Resolution <= 5 || model.Resolution == 10 {
resolution = model.Resolution
}
step := calculateStep(query.Interval, query.TimeRange.To.Sub(query.TimeRange.From), resolution)
qs = append(qs, &lokiQuery{
Expr: model.Expr,
Step: step,
LegendFormat: model.LegendFormat,
Start: start,
End: end,
RefID: query.RefID,
})
}
return qs, nil
}
func parseResponse(value *loghttp.QueryResponse, query *lokiQuery) (data.Frames, error) {
frames := data.Frames{}