mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 06:22:13 +08:00
fix(alerting): temp fix for broken AND condition
This should be refactored. lets return condition results instead of setting new value on the evalContext. The condition execution should only be able to update its own state. closes #6449
This commit is contained in:
@ -42,6 +42,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
||||
}
|
||||
|
||||
emptySerieCount := 0
|
||||
evalMatchCount := 0
|
||||
for _, series := range seriesList {
|
||||
reducedValue := c.Reducer.Reduce(series)
|
||||
evalMatch := c.Evaluator.Eval(reducedValue)
|
||||
@ -58,6 +59,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
||||
}
|
||||
|
||||
if evalMatch {
|
||||
evalMatchCount++
|
||||
context.EvalMatches = append(context.EvalMatches, &alerting.EvalMatch{
|
||||
Metric: series.Name,
|
||||
Value: reducedValue.Float64,
|
||||
@ -66,7 +68,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
|
||||
}
|
||||
|
||||
context.NoDataFound = emptySerieCount == len(seriesList)
|
||||
context.Firing = len(context.EvalMatches) > 0
|
||||
context.Firing = evalMatchCount > 0
|
||||
}
|
||||
|
||||
func (c *QueryCondition) executeQuery(context *alerting.EvalContext, timeRange *tsdb.TimeRange) (tsdb.TimeSeriesSlice, error) {
|
||||
|
Reference in New Issue
Block a user