From 62075aa037495e8b14b580ec26ca567e64080566 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Tue, 15 Dec 2015 12:11:38 +0100 Subject: [PATCH] Reduce noisy no-alertmanager warning --- cmd/prometheus/main.go | 1 - notification/notification.go | 6 +++++- rules/manager_test.go | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index c3a1c1475b..00aa3f87c8 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -155,7 +155,6 @@ func Main() int { prometheus.MustRegister(configSuccess) prometheus.MustRegister(configSuccessTime) - // go ruleManager.Run() defer ruleManager.Stop() go notificationHandler.Run() diff --git a/notification/notification.go b/notification/notification.go index 00c5f7f2af..500c43eaf0 100644 --- a/notification/notification.go +++ b/notification/notification.go @@ -159,6 +159,11 @@ func (n *Handler) nextBatch() []*model.Alert { // Run dispatches notifications continuously. func (n *Handler) Run() { + // Just warn one in the beginning to prevent nosiy logs. + if n.opts.AlertmanagerURL == "" { + log.Warnf("No AlertManager configured, not dispatching any alerts") + } + for { select { case <-n.ctx.Done(): @@ -172,7 +177,6 @@ func (n *Handler) Run() { continue } if n.opts.AlertmanagerURL == "" { - log.Warn("No AlertManager configured, not dispatching %d alerts", len(alerts)) n.dropped.Add(float64(len(alerts))) continue } diff --git a/rules/manager_test.go b/rules/manager_test.go index ffec7974b9..463388e154 100644 --- a/rules/manager_test.go +++ b/rules/manager_test.go @@ -15,7 +15,6 @@ package rules import ( "fmt" - // "reflect" "strings" "testing" "time"