From ff5d4e8e0c8fd83243cc4131a409d19ae42d9084 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 3 Nov 2016 07:14:34 +0100 Subject: [PATCH] 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 --- pkg/services/alerting/conditions/query.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/services/alerting/conditions/query.go b/pkg/services/alerting/conditions/query.go index a9a99ba919e..7cf255c6af8 100644 --- a/pkg/services/alerting/conditions/query.go +++ b/pkg/services/alerting/conditions/query.go @@ -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) {