The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/ngalert/backtesting/eval_query.go

27 lines
582 B

package backtesting
import (
"context"
"time"
"github.com/grafana/grafana/pkg/services/ngalert/eval"
)
// QueryEvaluator is evaluator of regular alert rule queries
type queryEvaluator struct {
eval eval.ConditionEvaluator
}
func (d *queryEvaluator) Eval(ctx context.Context, from, to time.Time, interval time.Duration, callback callbackFunc) error {
for now := from; now.Before(to); now = now.Add(interval) {
results, err := d.eval.Evaluate(ctx, now)
if err != nil {
return err
}
err = callback(now, results)
if err != nil {
return err
}
}
return nil
}