Alerting: Keep last state on no data (#6354)

* feat(alerting): add support to keep last state on no data

closes #6332

* refactoring(alerting PR #6354): added new option type for NoData option so AlertStateType does not have to contain invalid state, #6354
This commit is contained in:
Carl Bergquist
2016-10-22 10:56:04 +02:00
committed by Torkel Ödegaard
parent 4999fff29b
commit bc90e6ce46
5 changed files with 41 additions and 47 deletions
+16
View File
@@ -8,6 +8,7 @@ import (
type AlertStateType string
type AlertSeverityType string
type NoDataOption string
const (
AlertStateNoData AlertStateType = "no_data"
@@ -17,10 +18,25 @@ const (
AlertStateOK AlertStateType = "ok"
)
const (
NoDataSetNoData NoDataOption = "no_data"
NoDataSetAlerting NoDataOption = "alerting"
NoDataSetOK NoDataOption = "ok"
NoDataKeepState NoDataOption = "keep_state"
)
func (s AlertStateType) IsValid() bool {
return s == AlertStateOK || s == AlertStateNoData || s == AlertStateExecError || s == AlertStatePaused
}
func (s NoDataOption) IsValid() bool {
return s == NoDataSetNoData || s == NoDataSetAlerting || s == NoDataSetOK || s == NoDataKeepState
}
func (s NoDataOption) ToAlertState() AlertStateType {
return AlertStateType(s)
}
type Alert struct {
Id int64
Version int64