Skip to content

Commit

Permalink
cmd/alermanager: log when repeat_interval > retention (#1993)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
  • Loading branch information
simonpasquier authored Aug 7, 2019
1 parent 655947d commit f8428bf
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion cmd/alertmanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ func buildReceiverIntegrations(nc *config.Receiver, tmpl *template.Template, log
}
return integrations, nil
}

// walkRoute traverses the route tree in depth-first order.
func walkRoute(r *dispatch.Route, visit func(*dispatch.Route)) {
visit(r)
if r.Routes == nil {
return
}
for i := range r.Routes {
walkRoute(r.Routes[i], visit)
}
}

func main() {
os.Exit(run())
}
Expand Down Expand Up @@ -401,7 +413,22 @@ func run() int {
silencer.Mutes(labels)
})

disp = dispatch.NewDispatcher(alerts, dispatch.NewRoute(conf.Route, nil), pipeline, marker, timeoutFunc, logger)
routes := dispatch.NewRoute(conf.Route, nil)
disp = dispatch.NewDispatcher(alerts, routes, pipeline, marker, timeoutFunc, logger)
walkRoute(routes, func(r *dispatch.Route) {
if r.RouteOpts.RepeatInterval > *retention {
level.Warn(log.With(logger, "component", "configuration")).Log(
"msg",
"repeat_interval is greater than the data retention period. It can lead to notifications being repeated more often than expected.",
"repeat_interval",
r.RouteOpts.RepeatInterval,
"retention",
*retention,
"route",
r.Key(),
)
}
})

go disp.Run()
go inhibitor.Run()
Expand Down

0 comments on commit f8428bf

Please sign in to comment.