From cbfbf07188b4df8983cbc4be311e4da2521e49d2 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 22 Sep 2020 17:14:12 +1000 Subject: [PATCH] Allow routes to reference time intervals Signed-off-by: Ben Ridley --- dispatch/route.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dispatch/route.go b/dispatch/route.go index bb6477dd..bcb3f5ae 100644 --- a/dispatch/route.go +++ b/dispatch/route.go @@ -34,6 +34,7 @@ var DefaultRouteOpts = RouteOpts{ RepeatInterval: 4 * time.Hour, GroupBy: map[model.LabelName]struct{}{}, GroupByAll: false, + MuteTimes: []string{}, } // A Route is a node that contains definitions of how to handle alerts. @@ -65,6 +66,7 @@ func NewRoute(cr *config.Route, parent *Route) *Route { if cr.Receiver != "" { opts.Receiver = cr.Receiver } + if cr.GroupBy != nil { opts.GroupBy = map[model.LabelName]struct{}{} for _, ln := range cr.GroupBy { @@ -115,6 +117,8 @@ func NewRoute(cr *config.Route, parent *Route) *Route { sort.Sort(matchers) + opts.MuteTimes = cr.MuteTimes + route := &Route{ parent: parent, RouteOpts: opts, @@ -203,6 +207,9 @@ type RouteOpts struct { GroupWait time.Duration GroupInterval time.Duration RepeatInterval time.Duration + + // A list of time intervals for which the route is muted + MuteTimes []string } func (ro *RouteOpts) String() string {