Alerting: Fix stale values associated with states that have gone to NoData, unify values calculation (#89807)

* Unify values

* Fix with latest changes on main

* Fix up NaN test

* Keep refIDs with -1 as value

* Test that refIDs are preserved on Normal to Error transition

* Alerting to err test too

* Add a blurb to docs about this behavior
This commit is contained in:
Alexander Weaver
2024-07-08 12:30:23 -05:00
committed by GitHub
parent f763f2085b
commit 3b6a8775bb
11 changed files with 209 additions and 82 deletions
-28
View File
@@ -238,34 +238,6 @@ func Test_getOrCreate(t *testing.T) {
}
})
t.Run("expected Reduce and Math expression values", func(t *testing.T) {
result := eval.Result{
Instance: models.GenerateAlertLabels(5, "result-"),
Values: map[string]eval.NumberValueCapture{
"A": {Var: "A", Value: util.Pointer(1.0)},
"B": {Var: "B", Value: util.Pointer(2.0)},
},
}
rule := generateRule()
state := c.getOrCreate(context.Background(), l, rule, result, nil, url)
assert.Equal(t, map[string]float64{"A": 1, "B": 2}, state.Values)
})
t.Run("expected Classic Condition values", func(t *testing.T) {
result := eval.Result{
Instance: models.GenerateAlertLabels(5, "result-"),
Values: map[string]eval.NumberValueCapture{
"B0": {Var: "B", Value: util.Pointer(1.0)},
"B1": {Var: "B", Value: util.Pointer(2.0)},
},
}
rule := generateRule()
state := c.getOrCreate(context.Background(), l, rule, result, nil, url)
assert.Equal(t, map[string]float64{"B0": 1, "B1": 2}, state.Values)
})
t.Run("when result labels collide with system labels from LabelsUserCannotSpecify", func(t *testing.T) {
result := eval.Result{
Instance: models.GenerateAlertLabels(5, "result-"),