diff --git a/app/vmalert/config/config.go b/app/vmalert/config/config.go index 8a21cc90b..ce873ccf7 100644 --- a/app/vmalert/config/config.go +++ b/app/vmalert/config/config.go @@ -24,7 +24,7 @@ type Group struct { Type datasource.Type `yaml:"type,omitempty"` File string Name string `yaml:"name"` - Interval utils.PromDuration `yaml:"interval,omitempty"` + Interval utils.PromDuration `yaml:"interval"` Rules []Rule `yaml:"rules"` Concurrency int `yaml:"concurrency"` // ExtraFilterLabels is a list label filters applied to every rule diff --git a/app/vmalert/config/config_test.go b/app/vmalert/config/config_test.go index bb7f1e4a5..5a2bbea94 100644 --- a/app/vmalert/config/config_test.go +++ b/app/vmalert/config/config_test.go @@ -436,7 +436,7 @@ rules: `) }) - t.Run("Ok, `for` must change cs", func(t *testing.T) { + t.Run("`for` change", func(t *testing.T) { f(t, ` name: TestGroup rules: @@ -450,5 +450,34 @@ rules: expr: sum by(job) (up == 1) `) }) - + t.Run("`interval` change", func(t *testing.T) { + f(t, ` +name: TestGroup +interval: 2s +rules: + - alert: ExampleAlertWithFor + expr: sum by(job) (up == 1) +`, ` +name: TestGroup +interval: 4s +rules: + - alert: ExampleAlertWithFor + expr: sum by(job) (up == 1) +`) + }) + t.Run("`concurrency` change", func(t *testing.T) { + f(t, ` +name: TestGroup +concurrency: 2 +rules: + - alert: ExampleAlertWithFor + expr: sum by(job) (up == 1) +`, ` +name: TestGroup +concurrency: 16 +rules: + - alert: ExampleAlertWithFor + expr: sum by(job) (up == 1) +`) + }) } diff --git a/app/vmalert/group.go b/app/vmalert/group.go index 1e5e8c8ac..e80b1e6e8 100644 --- a/app/vmalert/group.go +++ b/app/vmalert/group.go @@ -190,6 +190,9 @@ func (g *Group) updateWith(newGroup *Group) error { for _, nr := range rulesRegistry { newRules = append(newRules, nr) } + // note that g.Interval is not updated here + // so the value can be compared later in + // group.Start function g.Type = newGroup.Type g.Concurrency = newGroup.Concurrency g.ExtraFilterLabels = newGroup.ExtraFilterLabels