Alerting: Fix NoDataFound for alert rules using the AND operator (#41305)
This commit fixes an issue in alerting where NoDataFound is false when using the AND operator to compare two conditions in an alert rule and one of the conditions has no data.
This commit is contained in:
@@ -52,12 +52,15 @@ func (e *DefaultEvalHandler) Eval(context *EvalContext) {
|
||||
// calculating Firing based on operator
|
||||
if cr.Operator == "or" {
|
||||
firing = firing || cr.Firing
|
||||
noDataFound = noDataFound || cr.NoDataFound
|
||||
} else {
|
||||
firing = firing && cr.Firing
|
||||
noDataFound = noDataFound && cr.NoDataFound
|
||||
}
|
||||
|
||||
// We cannot evaluate the expression when one or more conditions are missing data
|
||||
// and so noDataFound should be true if at least one condition returns no data,
|
||||
// irrespective of the operator.
|
||||
noDataFound = noDataFound || cr.NoDataFound
|
||||
|
||||
if i > 0 {
|
||||
conditionEvals = "[" + conditionEvals + " " + strings.ToUpper(cr.Operator) + " " + strconv.FormatBool(cr.Firing) + "]"
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user