From b7bea3df5c1ab6a7d4238974f50158a712e2527d Mon Sep 17 00:00:00 2001 From: Conor Broderick Date: Fri, 24 Mar 2017 14:06:39 +0000 Subject: [PATCH] Renamed from and message options for VictorOps to monitoring_tool and state_message as per the VictorOps documentation (#667) --- config/notifiers.go | 18 +++++++++--------- notify/impl.go | 16 ++++++++-------- template/default.tmpl | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/config/notifiers.go b/config/notifiers.go index 77ee120e..53cc3d43 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -98,9 +98,9 @@ var ( NotifierConfig: NotifierConfig{ VSendResolved: true, }, - MessageType: `CRITICAL`, - StateMessage: `{{ template "victorops.default.message" . }}`, - From: `{{ template "victorops.default.from" . }}`, + MessageType: `CRITICAL`, + StateMessage: `{{ template "victorops.default.state_message" . }}`, + MonitoringTool: `{{ template "victorops.default.monitoring_tool" . }}`, } // DefaultPushoverConfig defines default values for Pushover configurations. @@ -321,12 +321,12 @@ func (c *OpsGenieConfig) UnmarshalYAML(unmarshal func(interface{}) error) error type VictorOpsConfig struct { NotifierConfig `yaml:",inline" json:",inline"` - APIKey Secret `yaml:"api_key" json:"api_key"` - APIURL string `yaml:"api_url" json:"api_url"` - RoutingKey string `yaml:"routing_key" json:"routing_key"` - MessageType string `yaml:"message_type" json:"message_type"` - StateMessage string `yaml:"message" json:"message"` - From string `yaml:"from" json:"from"` + APIKey Secret `yaml:"api_key" json:"api_key"` + APIURL string `yaml:"api_url" json:"api_url"` + RoutingKey string `yaml:"routing_key" json:"routing_key"` + MessageType string `yaml:"message_type" json:"message_type"` + StateMessage string `yaml:"state_message" json:"state_message"` + MonitoringTool string `yaml:"monitoring_tool" json:"monitoring_tool"` XXX map[string]interface{} `yaml:",inline" json:"-"` } diff --git a/notify/impl.go b/notify/impl.go index 6645ddfd..1e7c5e86 100644 --- a/notify/impl.go +++ b/notify/impl.go @@ -763,10 +763,10 @@ const ( ) type victorOpsMessage struct { - MessageType string `json:"message_type"` - EntityID model.Fingerprint `json:"entity_id"` - StateMessage string `json:"state_message"` - From string `json:"monitoring_tool"` + MessageType string `json:"message_type"` + EntityID model.Fingerprint `json:"entity_id"` + StateMessage string `json:"state_message"` + MonitoringTool string `json:"monitoring_tool"` } type victorOpsErrorResponse struct { @@ -805,10 +805,10 @@ func (n *VictorOps) Notify(ctx context.Context, as ...*types.Alert) (bool, error } msg := &victorOpsMessage{ - MessageType: messageType, - EntityID: key, - StateMessage: tmpl(n.conf.StateMessage), - From: tmpl(n.conf.From), + MessageType: messageType, + EntityID: key, + StateMessage: tmpl(n.conf.StateMessage), + MonitoringTool: tmpl(n.conf.MonitoringTool), } if err != nil { diff --git a/template/default.tmpl b/template/default.tmpl index 123a41a1..9e5cb0e0 100644 --- a/template/default.tmpl +++ b/template/default.tmpl @@ -46,8 +46,8 @@ Alerts Resolved: {{ define "opsgenie.default.source" }}{{ template "__alertmanagerURL" . }}{{ end }} -{{ define "victorops.default.message" }}{{ template "__subject" . }} | {{ template "__alertmanagerURL" . }}{{ end }} -{{ define "victorops.default.from" }}{{ template "__alertmanager" . }}{{ end }} +{{ define "victorops.default.state_message" }}{{ template "__subject" . }} | {{ template "__alertmanagerURL" . }}{{ end }} +{{ define "victorops.default.monitoring_tool" }}{{ template "__alertmanager" . }}{{ end }} {{ define "email.default.subject" }}{{ template "__subject" . }}{{ end }}