mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
execResults := queryDataResponseToExecutionResults(r.condition, response)
|
return EvaluateAlert(response, r.condition, now), nil
|
||||||
return evaluateExecutionResult(execResults, now), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type evaluatorImpl struct {
|
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.
|
// invalidEvalResultFormatError is an error for invalid format of the alert definition evaluation results.
|
||||||
type invalidEvalResultFormatError struct {
|
type invalidEvalResultFormatError struct {
|
||||||
refID string
|
refID string
|
||||||
|
Loading…
Reference in New Issue
Block a user