Commit 77783c02 by bergquist

fix(alerting): dont log null series

closes #6025
parent 852fd66c
......@@ -43,6 +43,11 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
reducedValue := c.Reducer.Reduce(series)
evalMatch := c.Evaluator.Eval(reducedValue)
if reducedValue == nil {
emptySerieCount++
continue
}
if context.IsTestRun {
context.Logs = append(context.Logs, &alerting.ResultLogEntry{
Message: fmt.Sprintf("Condition[%d]: Eval: %v, Metric: %s, Value: %1.3f", c.Index, evalMatch, series.Name, *reducedValue),
......@@ -55,11 +60,6 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext) {
Value: *reducedValue,
})
}
// handle no data scenario
if reducedValue == nil {
emptySerieCount++
}
}
context.NoDataFound = emptySerieCount == len(seriesList)
......
......@@ -85,6 +85,18 @@ func TestQueryCondition(t *testing.T) {
So(ctx.result.NoDataFound, ShouldBeTrue)
})
Convey("Should set NoDataFound both series contains null", func() {
one := float64(120)
ctx.series = tsdb.TimeSeriesSlice{
tsdb.NewTimeSeries("test1", [][2]*float64{{nil, &one}}),
tsdb.NewTimeSeries("test2", [][2]*float64{{nil, &one}}),
}
ctx.exec()
So(ctx.result.Error, ShouldBeNil)
So(ctx.result.NoDataFound, ShouldBeTrue)
})
Convey("Should not set NoDataFound if one serie is empty", func() {
one := float64(120)
two := float64(0)
......
......@@ -35,8 +35,9 @@ func (s *SchedulerImpl) Update(rules []*Rule) {
}
job.Rule = rule
job.Offset = ((rule.Frequency * 1000) / int64(len(rules))) * int64(i)
job.Offset = int64(math.Floor(float64(job.Offset) / 1000))
offset := ((rule.Frequency * 1000) / int64(len(rules))) * int64(i)
job.Offset = int64(math.Floor(float64(offset) / 1000))
jobs[rule.Id] = job
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment