Allow routes to reference time intervals

Signed-off-by: Ben Ridley <benridley29@gmail.com>
This commit is contained in:
ben 2020-09-22 17:14:12 +10:00 committed by Ben Ridley
parent 5df661653c
commit cbfbf07188
1 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,7 @@ var DefaultRouteOpts = RouteOpts{
RepeatInterval: 4 * time.Hour, RepeatInterval: 4 * time.Hour,
GroupBy: map[model.LabelName]struct{}{}, GroupBy: map[model.LabelName]struct{}{},
GroupByAll: false, GroupByAll: false,
MuteTimes: []string{},
} }
// A Route is a node that contains definitions of how to handle alerts. // 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 != "" { if cr.Receiver != "" {
opts.Receiver = cr.Receiver opts.Receiver = cr.Receiver
} }
if cr.GroupBy != nil { if cr.GroupBy != nil {
opts.GroupBy = map[model.LabelName]struct{}{} opts.GroupBy = map[model.LabelName]struct{}{}
for _, ln := range cr.GroupBy { for _, ln := range cr.GroupBy {
@ -115,6 +117,8 @@ func NewRoute(cr *config.Route, parent *Route) *Route {
sort.Sort(matchers) sort.Sort(matchers)
opts.MuteTimes = cr.MuteTimes
route := &Route{ route := &Route{
parent: parent, parent: parent,
RouteOpts: opts, RouteOpts: opts,
@ -203,6 +207,9 @@ type RouteOpts struct {
GroupWait time.Duration GroupWait time.Duration
GroupInterval time.Duration GroupInterval time.Duration
RepeatInterval time.Duration RepeatInterval time.Duration
// A list of time intervals for which the route is muted
MuteTimes []string
} }
func (ro *RouteOpts) String() string { func (ro *RouteOpts) String() string {