From c5d1c4861022ee6d369c493548ce2325b0c393bd Mon Sep 17 00:00:00 2001 From: Dave McLain Date: Thu, 12 May 2016 13:51:22 -0500 Subject: [PATCH] Add support for overriding the icon_url slack parameter --- config/notifiers.go | 2 ++ notify/impl.go | 2 ++ template/default.tmpl | 1 + 3 files changed, 5 insertions(+) diff --git a/config/notifiers.go b/config/notifiers.go index 6ff8b802..c3a3f4ec 100644 --- a/config/notifiers.go +++ b/config/notifiers.go @@ -65,6 +65,7 @@ var ( Title: `{{ template "slack.default.title" . }}`, TitleLink: `{{ template "slack.default.titlelink" . }}`, IconEmoji: `{{ template "slack.default.iconemoji" . }}`, + IconURL: `{{ template "slack.default.iconurl" . }}`, Pretext: `{{ template "slack.default.pretext" . }}`, Text: `{{ template "slack.default.text" . }}`, Fallback: `{{ template "slack.default.fallback" . }}`, @@ -204,6 +205,7 @@ type SlackConfig struct { Text string `yaml:"text"` Fallback string `yaml:"fallback"` IconEmoji string `yaml:"icon_emoji"` + IconURL string `yaml:"icon_url"` // Catches all undefined fields and must be empty after parsing. XXX map[string]interface{} `yaml:",inline"` diff --git a/notify/impl.go b/notify/impl.go index a4eadfe4..ed660e16 100644 --- a/notify/impl.go +++ b/notify/impl.go @@ -463,6 +463,7 @@ type slackReq struct { Channel string `json:"channel,omitempty"` Username string `json:"username,omitempty"` IconEmoji string `json:"icon_emoji,omitempty"` + IconURL string `json:"icon_url,omitempty"` Attachments []slackAttachment `json:"attachments"` } @@ -506,6 +507,7 @@ func (n *Slack) Notify(ctx context.Context, as ...*types.Alert) error { Channel: tmplText(n.conf.Channel), Username: tmplText(n.conf.Username), IconEmoji: tmplText(n.conf.IconEmoji), + IconURL: tmplText(n.conf.IconURL), Attachments: []slackAttachment{*attachment}, } if err != nil { diff --git a/template/default.tmpl b/template/default.tmpl index 6f811054..b6d2246e 100644 --- a/template/default.tmpl +++ b/template/default.tmpl @@ -18,6 +18,7 @@ {{ define "slack.default.pretext" }}{{ end }} {{ define "slack.default.titlelink" }}{{ template "__alertmanagerURL" . }}{{ end }} {{ define "slack.default.iconemoji" }}{{ end }} +{{ define "slack.default.iconurl" }}{{ end }} {{ define "slack.default.text" }}{{ end }}