From b655aa002fba7beaf2da30a038e0e6c5c41d4e03 Mon Sep 17 00:00:00 2001 From: Frederic Branczyk Date: Tue, 9 Aug 2016 13:09:36 +0200 Subject: [PATCH] introduce top level alerting config node --- config/config.go | 13 +++++++++---- notifier/notifier.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index 942c5322b..6a4042b92 100644 --- a/config/config.go +++ b/config/config.go @@ -176,10 +176,10 @@ func (u URL) MarshalYAML() (interface{}, error) { // Config is the top-level configuration for Prometheus's config files. type Config struct { - GlobalConfig GlobalConfig `yaml:"global"` - AlertRelabelConfigs []*RelabelConfig `yaml:"alert_relabel_configs,omitempty"` - RuleFiles []string `yaml:"rule_files,omitempty"` - ScrapeConfigs []*ScrapeConfig `yaml:"scrape_configs,omitempty"` + GlobalConfig GlobalConfig `yaml:"global"` + AlertingConfig AlertingConfig `yaml:"alerting,omitempty"` + RuleFiles []string `yaml:"rule_files,omitempty"` + ScrapeConfigs []*ScrapeConfig `yaml:"scrape_configs,omitempty"` // Catches all undefined fields and must be empty after parsing. XXX map[string]interface{} `yaml:",inline"` @@ -293,6 +293,11 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { return nil } +// AlertingConfig configures alerting and alertmanager related configs +type AlertingConfig struct { + AlertRelabelConfigs []*RelabelConfig `yaml:"alert_relabel_configs,omitempty"` +} + // GlobalConfig configures values that are used across other configuration // objects. type GlobalConfig struct { diff --git a/notifier/notifier.go b/notifier/notifier.go index 75360aa47..2e36b62b7 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -138,7 +138,7 @@ func (n *Notifier) ApplyConfig(conf *config.Config) error { defer n.mtx.Unlock() n.opts.ExternalLabels = conf.GlobalConfig.ExternalLabels - n.opts.RelabelConfigs = conf.AlertRelabelConfigs + n.opts.RelabelConfigs = conf.AlertingConfig.AlertRelabelConfigs return nil }