Skip to content

Commit

Permalink
Add footer field for slack messages (prometheus#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartnelson3 authored Dec 12, 2017
1 parent 873623e commit 7736ea0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config/notifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var (
Pretext: `{{ template "slack.default.pretext" . }}`,
Text: `{{ template "slack.default.text" . }}`,
Fallback: `{{ template "slack.default.fallback" . }}`,
Footer: `{{ template "slack.default.footer" . }}`,
}

// DefaultHipchatConfig defines default values for Hipchat configurations.
Expand Down Expand Up @@ -237,6 +238,7 @@ type SlackConfig struct {
TitleLink string `yaml:"title_link,omitempty" json:"title_link,omitempty"`
Pretext string `yaml:"pretext,omitempty" json:"pretext,omitempty"`
Text string `yaml:"text,omitempty" json:"text,omitempty"`
Footer string `yaml:"footer,omitempty" json:"footer,omitempty"`
Fallback string `yaml:"fallback,omitempty" json:"fallback,omitempty"`
IconEmoji string `yaml:"icon_emoji,omitempty" json:"icon_emoji,omitempty"`
IconURL string `yaml:"icon_url,omitempty" json:"icon_url,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions notify/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ type slackAttachment struct {
Pretext string `json:"pretext,omitempty"`
Text string `json:"text"`
Fallback string `json:"fallback"`
Footer string `json:"footer"`

Color string `json:"color,omitempty"`
MrkdwnIn []string `json:"mrkdwn_in,omitempty"`
Expand All @@ -657,6 +658,7 @@ func (n *Slack) Notify(ctx context.Context, as ...*types.Alert) (bool, error) {
Pretext: tmplText(n.conf.Pretext),
Text: tmplText(n.conf.Text),
Fallback: tmplText(n.conf.Fallback),
Footer: tmplText(n.conf.Footer),
Color: tmplText(n.conf.Color),
MrkdwnIn: []string{"fallback", "pretext", "text"},
}
Expand Down
1 change: 1 addition & 0 deletions template/default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{{ define "slack.default.iconemoji" }}{{ end }}
{{ define "slack.default.iconurl" }}{{ end }}
{{ define "slack.default.text" }}{{ end }}
{{ define "slack.default.footer" }}{{ end }}


{{ define "hipchat.default.from" }}{{ template "__alertmanager" . }}{{ end }}
Expand Down
Loading

0 comments on commit 7736ea0

Please sign in to comment.