Allow time intervals in global config
Signed-off-by: Ben Ridley <benridley29@gmail.com>
This commit is contained in:
parent
c2c0c5544d
commit
5df661653c
|
@ -25,6 +25,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/benridley/gotime"
|
||||
"github.com/pkg/errors"
|
||||
commoncfg "github.com/prometheus/common/config"
|
||||
"github.com/prometheus/common/model"
|
||||
|
@ -219,6 +220,12 @@ func resolveFilepaths(baseDir string, cfg *Config) {
|
|||
}
|
||||
}
|
||||
|
||||
// A MuteTimeInterval represents a named set of time intervals for which a route should be muted
|
||||
type MuteTimeInterval struct {
|
||||
Name string `yaml:"name" json:"name"`
|
||||
TimeIntervals []gotime.TimeInterval `yaml:"time_intervals"`
|
||||
}
|
||||
|
||||
// Config is the top-level configuration for Alertmanager's config files.
|
||||
type Config struct {
|
||||
Global *GlobalConfig `yaml:"global,omitempty" json:"global,omitempty"`
|
||||
|
@ -411,6 +418,9 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
if len(c.Route.Match) > 0 || len(c.Route.MatchRE) > 0 {
|
||||
return fmt.Errorf("root route must not have any matchers")
|
||||
}
|
||||
if len(c.Route.MuteTimes) > 0 {
|
||||
return fmt.Errorf("root route cannot have any mute times")
|
||||
}
|
||||
|
||||
// Validate that all receivers used in the routing tree are defined.
|
||||
return checkReceiver(c.Route, names)
|
||||
|
@ -438,7 +448,7 @@ func DefaultGlobalConfig() GlobalConfig {
|
|||
return GlobalConfig{
|
||||
ResolveTimeout: model.Duration(5 * time.Minute),
|
||||
HTTPConfig: &commoncfg.HTTPClientConfig{},
|
||||
|
||||
MuteTimeIntervals: []MuteTimeInterval{},
|
||||
SMTPHello: "localhost",
|
||||
SMTPRequireTLS: true,
|
||||
PagerdutyURL: mustParseURL("https://events.pagerduty.com/v2/enqueue"),
|
||||
|
@ -555,6 +565,7 @@ type GlobalConfig struct {
|
|||
SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"`
|
||||
SMTPRequireTLS bool `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"`
|
||||
SlackAPIURL *SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"`
|
||||
MuteTimeIntervals []MuteTimeInterval `yaml:"mute_time_intervals,omitempty" json:"mute_time_intervals,omitempty"`
|
||||
PagerdutyURL *URL `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"`
|
||||
OpsGenieAPIURL *URL `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"`
|
||||
OpsGenieAPIKey Secret `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"`
|
||||
|
@ -579,11 +590,10 @@ type Route struct {
|
|||
GroupByStr []string `yaml:"group_by,omitempty" json:"group_by,omitempty"`
|
||||
GroupBy []model.LabelName `yaml:"-" json:"-"`
|
||||
GroupByAll bool `yaml:"-" json:"-"`
|
||||
// Deprecated. Remove before v1.0 release.
|
||||
|
||||
Match map[string]string `yaml:"match,omitempty" json:"match,omitempty"`
|
||||
// Deprecated. Remove before v1.0 release.
|
||||
MatchRE MatchRegexps `yaml:"match_re,omitempty" json:"match_re,omitempty"`
|
||||
Matchers Matchers `yaml:"matchers,omitempty" json:"matchers,omitempty"`
|
||||
MuteTimes []string `yaml:"mute_times,omitempty" json:"mute_times,omitempty"`
|
||||
Continue bool `yaml:"continue" json:"continue,omitempty"`
|
||||
Routes []*Route `yaml:"routes,omitempty" json:"routes,omitempty"`
|
||||
|
||||
|
|
Loading…
Reference in New Issue