Alerting: Add exported API to scheduler to access currently loaded rules (#82031)

* Add exported API to fetch rule definitions from scheduler

* Add comment
This commit is contained in:
Alexander Weaver 2024-02-07 09:31:22 -06:00 committed by GitHub
parent 9fb04be7ff
commit 843c477899
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -155,6 +155,13 @@ func (sch *schedule) Run(ctx context.Context) error {
return nil
}
// Rules fetches the entire set of rules considered for evaluation by the scheduler on the next tick.
// Such rules are not guaranteed to have been evaluated by the scheduler.
// Rules returns all supplementary metadata for the rules that is stored by the scheduler - namely, the set of folder titles.
func (sch *schedule) Rules() ([]*ngmodels.AlertRule, map[ngmodels.FolderKey]string) {
return sch.schedulableAlertRules.all()
}
// deleteAlertRule stops evaluation of the rule, deletes it from active rules, and cleans up state cache.
func (sch *schedule) deleteAlertRule(keys ...ngmodels.AlertRuleKey) {
for _, key := range keys {