mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
This pull request adds metrics to the ngalert scheduler so we can see how long it takes to evaluate a tick.
25 lines
528 B
Go
25 lines
528 B
Go
package schedule
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
|
)
|
|
|
|
func (sch *schedule) getAlertRules(disabledOrgs []int64) []*models.AlertRule {
|
|
start := time.Now()
|
|
defer func() {
|
|
sch.metrics.GetAlertRulesDuration.Observe(time.Since(start).Seconds())
|
|
}()
|
|
|
|
q := models.ListAlertRulesQuery{
|
|
ExcludeOrgs: disabledOrgs,
|
|
}
|
|
err := sch.ruleStore.GetAlertRulesForScheduling(&q)
|
|
if err != nil {
|
|
sch.log.Error("failed to fetch alert definitions", "err", err)
|
|
return nil
|
|
}
|
|
return q.Result
|
|
}
|