diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index 1043bd3df..30e8869d3 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -155,6 +155,7 @@ func Main() int { prometheus.MustRegister(configSuccess) prometheus.MustRegister(configSuccessTime) + go ruleManager.Run() defer ruleManager.Stop() go notificationHandler.Run() diff --git a/rules/manager.go b/rules/manager.go index 3592e76fb..84eb0697e 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -325,6 +325,7 @@ type Manager struct { opts *ManagerOptions groups map[string]*Group mtx sync.RWMutex + block chan struct{} } // ManagerOptions bundles options for the Manager. @@ -341,10 +342,16 @@ func NewManager(o *ManagerOptions) *Manager { manager := &Manager{ groups: map[string]*Group{}, opts: o, + block: make(chan struct{}), } return manager } +// Run starts processing of the rule manager. +func (m *Manager) Run() { + close(m.block) +} + // Stop the rule manager's rule evaluation cycles. func (m *Manager) Stop() { log.Info("Stopping rule manager...") @@ -398,7 +405,13 @@ func (m *Manager) ApplyConfig(conf *config.Config) bool { oldg.stop() newg.copyState(oldg) } - go newg.run() + go func() { + // Wait with starting evaluation until the rule manager + // is told to run. This is necessary to avoid running + // queries against a bootstrapping storage. + <-m.block + newg.run() + }() wg.Done() }(newg) } diff --git a/web/ui/bindata.go b/web/ui/bindata.go index 92ccc2bd5..2c968cb04 100644 --- a/web/ui/bindata.go +++ b/web/ui/bindata.go @@ -134,7 +134,7 @@ func webUiTemplatesAlertsHtml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "web/ui/templates/alerts.html", size: 1704, mode: os.FileMode(420), modTime: time.Unix(1450348695, 0)} + info := bindataFileInfo{name: "web/ui/templates/alerts.html", size: 1704, mode: os.FileMode(420), modTime: time.Unix(1450878652, 0)} a := &asset{bytes: bytes, info: info} return a, nil }