Commit ea4b14ac by bergquist

feat(alerting): rename critical -> crit

parent 212fd272
...@@ -63,7 +63,7 @@ func NewAlertRuleFromDBModel(ruleDef *m.Alert) (*AlertRule, error) { ...@@ -63,7 +63,7 @@ func NewAlertRuleFromDBModel(ruleDef *m.Alert) (*AlertRule, error) {
model.State = ruleDef.State model.State = ruleDef.State
model.Frequency = ruleDef.Frequency model.Frequency = ruleDef.Frequency
critical := ruleDef.Settings.Get("critical") critical := ruleDef.Settings.Get("crit")
model.Critical = Level{ model.Critical = Level{
Operator: critical.Get("op").MustString(), Operator: critical.Get("op").MustString(),
Value: critical.Get("value").MustFloat64(), Value: critical.Get("value").MustFloat64(),
......
...@@ -38,7 +38,7 @@ func TestAlertRuleModel(t *testing.T) { ...@@ -38,7 +38,7 @@ func TestAlertRuleModel(t *testing.T) {
"description": "desc2", "description": "desc2",
"handler": 0, "handler": 0,
"enabled": true, "enabled": true,
"critical": { "crit": {
"value": 20, "value": 20,
"op": ">" "op": ">"
}, },
...@@ -75,11 +75,12 @@ func TestAlertRuleModel(t *testing.T) { ...@@ -75,11 +75,12 @@ func TestAlertRuleModel(t *testing.T) {
alertRule, err := NewAlertRuleFromDBModel(alert) alertRule, err := NewAlertRuleFromDBModel(alert)
So(err, ShouldBeNil) So(err, ShouldBeNil)
So(alertRule.Critical.Operator, ShouldEqual, ">")
So(alertRule.Critical.Value, ShouldEqual, 20)
So(alertRule.Warning.Operator, ShouldEqual, ">") So(alertRule.Warning.Operator, ShouldEqual, ">")
So(alertRule.Warning.Value, ShouldEqual, 10) So(alertRule.Warning.Value, ShouldEqual, 10)
So(alertRule.Critical.Operator, ShouldEqual, ">")
So(alertRule.Critical.Value, ShouldEqual, 20)
}) })
}) })
} }
...@@ -102,7 +102,8 @@ func (e *HandlerImpl) evaluateRule(rule *AlertRule, series tsdb.TimeSeriesSlice) ...@@ -102,7 +102,8 @@ func (e *HandlerImpl) evaluateRule(rule *AlertRule, series tsdb.TimeSeriesSlice)
transformedValue, _ := rule.Transformer.Transform(serie) transformedValue, _ := rule.Transformer.Transform(serie)
critResult := evalCondition(rule.Critical, transformedValue) critResult := evalCondition(rule.Critical, transformedValue)
e.log.Debug("Alert execution Crit", "name", serie.Name, "transformedValue", transformedValue, "operator", rule.Critical.Operator, "level", rule.Critical.Value, "result", critResult) condition2 := fmt.Sprintf("%v %s %v ", transformedValue, rule.Critical.Operator, rule.Critical.Value)
e.log.Debug("Alert execution Crit", "name", serie.Name, "condition", condition2, "result", critResult)
if critResult { if critResult {
triggeredAlert = append(triggeredAlert, &TriggeredAlert{ triggeredAlert = append(triggeredAlert, &TriggeredAlert{
State: alertstates.Critical, State: alertstates.Critical,
...@@ -113,7 +114,8 @@ func (e *HandlerImpl) evaluateRule(rule *AlertRule, series tsdb.TimeSeriesSlice) ...@@ -113,7 +114,8 @@ func (e *HandlerImpl) evaluateRule(rule *AlertRule, series tsdb.TimeSeriesSlice)
} }
warnResult := evalCondition(rule.Warning, transformedValue) warnResult := evalCondition(rule.Warning, transformedValue)
e.log.Debug("Alert execution Warn", "name", serie.Name, "transformedValue", transformedValue, "operator", rule.Warning.Operator, "level", rule.Warning.Value, "result", warnResult) condition := fmt.Sprintf("%v %s %v ", transformedValue, rule.Warning.Operator, rule.Warning.Value)
e.log.Debug("Alert execution Warn", "name", serie.Name, "condition", condition, "result", warnResult)
if warnResult { if warnResult {
triggeredAlert = append(triggeredAlert, &TriggeredAlert{ triggeredAlert = append(triggeredAlert, &TriggeredAlert{
State: alertstates.Warn, State: alertstates.Warn,
......
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