mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 04:04:00 -06:00
Alerting: Export pure function to convert query results to alert results (#85393)
Exported pure function to convert query results to alert results
This commit is contained in:
parent
362c95c606
commit
734d0111cb
@ -83,8 +83,7 @@ func (r *conditionEvaluator) Evaluate(ctx context.Context, now time.Time) (Resul
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
execResults := queryDataResponseToExecutionResults(r.condition, response)
|
||||
return evaluateExecutionResult(execResults, now), nil
|
||||
return EvaluateAlert(response, r.condition, now), nil
|
||||
}
|
||||
|
||||
type evaluatorImpl struct {
|
||||
@ -108,6 +107,12 @@ func NewEvaluatorFactory(
|
||||
}
|
||||
}
|
||||
|
||||
// EvaluateAlert takes the results of an executed query and evaluates it as an alert rule, returning alert states that the query produces.
|
||||
func EvaluateAlert(queryResponse *backend.QueryDataResponse, condition models.Condition, now time.Time) Results {
|
||||
execResults := queryDataResponseToExecutionResults(condition, queryResponse)
|
||||
return evaluateExecutionResult(execResults, now)
|
||||
}
|
||||
|
||||
// invalidEvalResultFormatError is an error for invalid format of the alert definition evaluation results.
|
||||
type invalidEvalResultFormatError struct {
|
||||
refID string
|
||||
|
Loading…
Reference in New Issue
Block a user