diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index a84f36d586..20dc835064 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -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()) } @@ -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()