diff --git a/config/config.go b/config/config.go index 514808b7..2b41640d 100644 --- a/config/config.go +++ b/config/config.go @@ -202,10 +202,10 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { } for _, hc := range rcv.HipchatConfigs { if hc.APIURL == "" { - if c.Global.HipchatURL == "" { + if c.Global.HipchatAPIURL == "" { return fmt.Errorf("no global Hipchat API URL set") } - hc.APIURL = c.Global.HipchatURL + hc.APIURL = c.Global.HipchatAPIURL } if !strings.HasSuffix(hc.APIURL, "/") { hc.APIURL += "/" @@ -226,14 +226,14 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { } } for _, ogc := range rcv.OpsGenieConfigs { - if ogc.APIHost == "" { - if c.Global.OpsGenieAPIHost == "" { + if ogc.APIURL == "" { + if c.Global.OpsGenieAPIURL == "" { return fmt.Errorf("no global OpsGenie URL set") } - ogc.APIHost = c.Global.OpsGenieAPIHost + ogc.APIURL = c.Global.OpsGenieAPIURL } - if !strings.HasSuffix(ogc.APIHost, "/") { - ogc.APIHost += "/" + if !strings.HasSuffix(ogc.APIURL, "/") { + ogc.APIURL += "/" } } for _, voc := range rcv.VictorOpsConfigs { @@ -299,8 +299,8 @@ var DefaultGlobalConfig = GlobalConfig{ SMTPRequireTLS: true, PagerdutyURL: "https://events.pagerduty.com/v2/enqueue", - HipchatURL: "https://api.hipchat.com/", - OpsGenieAPIHost: "https://api.opsgenie.com/", + HipchatAPIURL: "https://api.hipchat.com/", + OpsGenieAPIURL: "https://api.opsgenie.com/", VictorOpsAPIURL: "https://alert.victorops.com/integrations/generic/20131114/alert/", } @@ -321,9 +321,9 @@ type GlobalConfig struct { SMTPRequireTLS bool `yaml:"smtp_require_tls,omitempty" json:"smtp_require_tls,omitempty"` SlackAPIURL Secret `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"` PagerdutyURL string `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"` - HipchatURL string `yaml:"hipchat_url,omitempty" json:"hipchat_url,omitempty"` + HipchatAPIURL string `yaml:"hipchat_api_url,omitempty" json:"hipchat_api_url,omitempty"` HipchatAuthToken Secret `yaml:"hipchat_auth_token,omitempty" json:"hipchat_auth_token,omitempty"` - OpsGenieAPIHost string `yaml:"opsgenie_api_host,omitempty" json:"opsgenie_api_host,omitempty"` + OpsGenieAPIURL string `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"` VictorOpsAPIURL string `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"` VictorOpsAPIKey Secret `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"` diff --git a/config/config_test.go b/config/config_test.go index df1c763d..851bcde5 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -280,11 +280,11 @@ func TestEmptyFieldsAndRegex(t *testing.T) { SMTPSmarthost: "localhost:25", SMTPFrom: "alertmanager@example.org", HipchatAuthToken: "mysecret", - HipchatURL: "https://hipchat.foobar.org/", + HipchatAPIURL: "https://hipchat.foobar.org/", SlackAPIURL: "mysecret", SMTPRequireTLS: true, PagerdutyURL: "https://events.pagerduty.com/v2/enqueue", - OpsGenieAPIHost: "https://api.opsgenie.com/", + OpsGenieAPIURL: "https://api.opsgenie.com/", VictorOpsAPIURL: "https://alert.victorops.com/integrations/generic/20131114/alert/", }, diff --git a/config/notifiers.go b/config/notifiers.go index 9eed7a36..fce20a43 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -300,7 +300,7 @@ type OpsGenieConfig struct { NotifierConfig `yaml:",inline" json:",inline"` APIKey Secret `yaml:"api_key,omitempty" json:"api_key,omitempty"` - APIHost string `yaml:"api_host,omitempty" json:"api_host,omitempty"` + APIURL string `yaml:"api_url,omitempty" json:"api_url,omitempty"` Message string `yaml:"message,omitempty" json:"message,omitempty"` Description string `yaml:"description,omitempty" json:"description,omitempty"` Source string `yaml:"source,omitempty" json:"source,omitempty"` diff --git a/config/testdata/conf.empty-fields.yml b/config/testdata/conf.empty-fields.yml index 34a41e59..5838dae9 100644 --- a/config/testdata/conf.empty-fields.yml +++ b/config/testdata/conf.empty-fields.yml @@ -5,7 +5,7 @@ global: smtp_auth_password: '' smtp_hello: '' hipchat_auth_token: 'mysecret' - hipchat_url: 'https://hipchat.foobar.org/' + hipchat_api_url: 'https://hipchat.foobar.org/' slack_api_url: 'mysecret' diff --git a/config/testdata/conf.good.yml b/config/testdata/conf.good.yml index 0334210c..861984aa 100644 --- a/config/testdata/conf.good.yml +++ b/config/testdata/conf.good.yml @@ -8,7 +8,7 @@ global: # The auth token for Hipchat. hipchat_auth_token: "mysecret" # Alternative host for Hipchat. - hipchat_url: 'https://hipchat.foobar.org/' + hipchat_api_url: 'https://hipchat.foobar.org/' slack_api_url: "mysecret" diff --git a/doc/examples/simple.yml b/doc/examples/simple.yml index 74821fcd..16788306 100644 --- a/doc/examples/simple.yml +++ b/doc/examples/simple.yml @@ -7,7 +7,7 @@ global: # The auth token for Hipchat. hipchat_auth_token: '1234556789' # Alternative host for Hipchat. - hipchat_url: 'https://hipchat.foobar.org/' + hipchat_api_url: 'https://hipchat.foobar.org/' # The directory from which notification templates are read. templates: diff --git a/notify/impl.go b/notify/impl.go index 42b42357..fbfc92d9 100644 --- a/notify/impl.go +++ b/notify/impl.go @@ -825,7 +825,7 @@ func (n *OpsGenie) Notify(ctx context.Context, as ...*types.Alert) (bool, error) ) switch alerts.Status() { case model.AlertResolved: - apiURL = fmt.Sprintf("%sv2/alerts/%s/close?identifierType=alias", n.conf.APIHost, alias) + apiURL = fmt.Sprintf("%sv2/alerts/%s/close?identifierType=alias", n.conf.APIURL, alias) msg = &opsGenieCloseMessage{Source: tmpl(n.conf.Source)} default: message := tmpl(n.conf.Message) @@ -834,7 +834,7 @@ func (n *OpsGenie) Notify(ctx context.Context, as ...*types.Alert) (bool, error) level.Debug(n.logger).Log("msg", "Truncated message to %q due to OpsGenie message limit", "truncated_message", message, "incident", key) } - apiURL = n.conf.APIHost + "v2/alerts" + apiURL = n.conf.APIURL + "v2/alerts" msg = &opsGenieCreateMessage{ Alias: alias, Message: message,