Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Slack additional "fields" to notifications #1135

Merged
merged 2 commits into from
Dec 15, 2017
Merged

Add Slack additional "fields" to notifications #1135

merged 2 commits into from
Dec 15, 2017

Conversation

rbtr
Copy link
Contributor

@rbtr rbtr commented Dec 10, 2017

Had a go at implementing #731

The Slack notification API has added a fields parameter that allows for some additional formatting [1]. It looks like the work was started to add this additional parameter [2], but the feature was never finished so that it was available.
[1] https://api.slack.com/docs/message-attachments#fields
[2] https://github.com/prometheus/alertmanager/blob/v0.5.1/notify/impl.go#L485-L490

Copy link
Contributor

@stuartnelson3 stuartnelson3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. could you fix the merge conflicts?

notify/impl.go Outdated
var fields = make([]slackAttachmentField, numFields)
for k, v := range n.conf.Fields {
fields[k] = slackAttachmentField{
v["title"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add tmplText() around both title and value, so the users can optionally define a template

notify/impl.go Outdated
@@ -669,8 +669,8 @@ func (n *Slack) Notify(ctx context.Context, as ...*types.Alert) (bool, error) {
var fields = make([]slackAttachmentField, numFields)
for k, v := range n.conf.Fields {
fields[k] = slackAttachmentField{
v["title"],
v["value"],
tmplText(v["title"]),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stuartnelson3 is this what you meant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, exactly

@stuartnelson3 stuartnelson3 merged commit 6a3dfaf into prometheus:master Dec 15, 2017
@rbtr rbtr deleted the slack-fields branch December 15, 2017 12:35
@rbtr
Copy link
Contributor Author

rbtr commented Dec 15, 2017

Closes #731

@JeanMertz
Copy link

This capability isn't documented anywhere on the Prometheus website, despite the latest release being from 13 days ago.

see: https://prometheus.io/docs/alerting/configuration/#%3Cslack_config%3E

Am I looking in the wrong place, or should the documentation be updated?

@rbtr
Copy link
Contributor Author

rbtr commented Feb 26, 2018

@JeanMertz i think the doc just needs to be updated. i'll see if i can contrib that

@stuartnelson3
Copy link
Contributor

@JeanMertz @rbtr yeah the docs need to be updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants