Add support for overriding the icon_url slack parameter

This commit is contained in:
Dave McLain 2016-05-12 13:51:22 -05:00
parent 22b4d74f7e
commit c5d1c48610
3 changed files with 5 additions and 0 deletions

View File

@ -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"`

View File

@ -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 {

View File

@ -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 }}