mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: alerting: handle variables like __interval and __range (#42126)
This commit is contained in:
@@ -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{}
|
||||
|
||||
|
Reference in New Issue
Block a user