feat(alerting): progress on handling no data in alert query, #5860

This commit is contained in:
Torkel Ödegaard
2016-09-06 20:40:12 +02:00
parent b1ed641d73
commit fbae6abb3c
18 changed files with 93 additions and 59 deletions
+8 -3
View File
@@ -41,7 +41,12 @@ func (handler *DefaultResultHandler) Handle(ctx *EvalContext) {
ctx.Rule.State = m.AlertStateType(ctx.Rule.Severity)
annotationData = simplejson.NewFromAny(ctx.EvalMatches)
} else {
ctx.Rule.State = m.AlertStateOK
// handle no data case
if ctx.NoDataFound {
ctx.Rule.State = ctx.Rule.NoDataState
} else {
ctx.Rule.State = m.AlertStateOK
}
}
countStateResult(ctx.Rule.State)
@@ -91,8 +96,8 @@ func countStateResult(state m.AlertStateType) {
metrics.M_Alerting_Result_State_Ok.Inc(1)
case m.AlertStatePaused:
metrics.M_Alerting_Result_State_Paused.Inc(1)
case m.AlertStatePending:
metrics.M_Alerting_Result_State_Pending.Inc(1)
case m.AlertStateUnknown:
metrics.M_Alerting_Result_State_Unknown.Inc(1)
case m.AlertStateExeuctionError:
metrics.M_Alerting_Result_State_ExecutionError.Inc(1)
}