Alerting: Update rules version when folder title is updated (#53013)

* remove support for bus from scheduler
* rename event to FolderTitleUpdated and fire only if title has changed
* add method to increase version of all rules that belong to a folder
* update ngalert service to subscribe to folder title change event call data store and update scheduler
* add tests
This commit is contained in:
Yuriy Tseretyan
2022-08-01 19:28:38 -04:00
committed by GitHub
parent b3f7deebda
commit 5fb778814c
12 changed files with 324 additions and 82 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/data"
models2 "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/util"
)
@@ -132,6 +133,18 @@ func WithSequentialGroupIndex() AlertRuleMutator {
}
}
func WithOrgID(orgId int64) AlertRuleMutator {
return func(rule *AlertRule) {
rule.OrgID = orgId
}
}
func WithNamespace(namespace *models2.Folder) AlertRuleMutator {
return func(rule *AlertRule) {
rule.NamespaceUID = namespace.Uid
}
}
func GenerateAlertLabels(count int, prefix string) data.Labels {
labels := make(data.Labels, count)
for i := 0; i < count; i++ {