mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Reduce set of fields that could trigger alert state change (#83496)
We want to avoid too much change of alert state based on change on alert's fields. For that we ignore some fields from the diff.
This commit is contained in:
parent
2188516a21
commit
6f38ac6615
@ -300,9 +300,7 @@ func (r ruleWithFolder) Fingerprint() fingerprint {
|
|||||||
// TODO consider removing fields below from the fingerprint
|
// TODO consider removing fields below from the fingerprint
|
||||||
writeInt(rule.ID)
|
writeInt(rule.ID)
|
||||||
writeInt(rule.OrgID)
|
writeInt(rule.OrgID)
|
||||||
writeInt(rule.IntervalSeconds)
|
|
||||||
writeInt(int64(rule.For))
|
writeInt(int64(rule.For))
|
||||||
writeLabels(rule.Annotations)
|
|
||||||
if rule.DashboardUID != nil {
|
if rule.DashboardUID != nil {
|
||||||
writeString(*rule.DashboardUID)
|
writeString(*rule.DashboardUID)
|
||||||
}
|
}
|
||||||
|
@ -150,10 +150,13 @@ func TestRuleWithFolderFingerprint(t *testing.T) {
|
|||||||
f2 := ruleWithFolder{rule: rule, folderTitle: uuid.NewString()}.Fingerprint()
|
f2 := ruleWithFolder{rule: rule, folderTitle: uuid.NewString()}.Fingerprint()
|
||||||
require.NotEqual(t, f, f2)
|
require.NotEqual(t, f, f2)
|
||||||
})
|
})
|
||||||
t.Run("Version and Updated should be excluded from fingerprint", func(t *testing.T) {
|
t.Run("Version, Updated, IntervalSeconds and Annotations should be excluded from fingerprint", func(t *testing.T) {
|
||||||
cp := models.CopyRule(rule)
|
cp := models.CopyRule(rule)
|
||||||
cp.Version++
|
cp.Version++
|
||||||
cp.Updated = cp.Updated.Add(1 * time.Second)
|
cp.Updated = cp.Updated.Add(1 * time.Second)
|
||||||
|
cp.IntervalSeconds++
|
||||||
|
cp.Annotations = make(map[string]string)
|
||||||
|
cp.Annotations["test"] = "test"
|
||||||
|
|
||||||
f2 := ruleWithFolder{rule: cp, folderTitle: title}.Fingerprint()
|
f2 := ruleWithFolder{rule: cp, folderTitle: title}.Fingerprint()
|
||||||
require.Equal(t, f, f2)
|
require.Equal(t, f, f2)
|
||||||
@ -240,8 +243,10 @@ func TestRuleWithFolderFingerprint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
excludedFields := map[string]struct{}{
|
excludedFields := map[string]struct{}{
|
||||||
"Version": {},
|
"Version": {},
|
||||||
"Updated": {},
|
"Updated": {},
|
||||||
|
"IntervalSeconds": {},
|
||||||
|
"Annotations": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
tp := reflect.TypeOf(rule).Elem()
|
tp := reflect.TypeOf(rule).Elem()
|
||||||
|
Loading…
Reference in New Issue
Block a user