diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 4c6d2c4a89..549a5b3fdd 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -838,6 +838,19 @@ func main() { }, ) } + if !agentMode { + // Rule manager. + g.Add( + func() error { + <-reloadReady.C + ruleManager.Run() + return nil + }, + func(err error) { + ruleManager.Stop() + }, + ) + } { // Scrape manager. g.Add( @@ -855,6 +868,8 @@ func main() { func(err error) { // Scrape manager needs to be stopped before closing the local TSDB // so that it doesn't try to write samples to a closed storage. + // We should also wait for rule manager to be fully stopped to ensure + // we don't trigger any false positive alerts for rules using absent(). level.Info(logger).Log("msg", "Stopping scrape manager...") scrapeManager.Stop() }, @@ -940,18 +955,6 @@ func main() { ) } if !agentMode { - // Rule manager. - g.Add( - func() error { - <-reloadReady.C - ruleManager.Run() - return nil - }, - func(err error) { - ruleManager.Stop() - }, - ) - // TSDB. opts := cfg.tsdb.ToTSDBOptions() cancel := make(chan struct{}) diff --git a/rules/manager.go b/rules/manager.go index 5ca05505d9..a9179bacf4 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -934,6 +934,7 @@ func NewManager(o *ManagerOptions) *Manager { // Run starts processing of the rule manager. It is blocking. func (m *Manager) Run() { + level.Info(m.logger).Log("msg", "Starting rule manager...") m.start() <-m.done }