Hey,
as already discussed in #650 it would be great to support custom Slack Attachments in the alert templates. Right now it's already used but only in a hardcoded way and it's not possible to add additional custom attachments.
This would be really helpful to structure alerts in a better way.
Thanks
Hate to dig up an old issue but this would be really helpful.
If I was to look into adding this, what would be the recommended approach with providing the receiver the different attachments to create? Where does n.conf.Fields come from that creates multiple attachmentFields?
an example yaml format might look like:
receivers:
- name: 'team-X-slack'
slack_configs:
- channel: "#ops"
attachments:
- text: ":fire:"
color: "#7CD197"
- text: "Help! The DC is burning!"
color: "#7CD197"
The PR that added fields is here: https://github.com/prometheus/alertmanager/commit/6a3dfaff
fields I suppose would be defined within each attachment in this new update. fields is just an array of dicts defined in the config.
so, define the attachments field within config.SlackConfig, and then use that parsed yaml to construct the attachments in the Notify method on notify.Slack.
These would be additional, optional attachments, which would be added to the current default attachment. This change should not require a config change on the part of anyone not wishing to use the additional attachments.
@stuartnelson3 If I try the config you've provided with v0.15.0-rc.2; I get:
caller=main.go:314 msg="Loading configuration file failed" file=/etc/config/alertmanager.yml err="yaml: unmarshal errors:\n line 6: field attachments not found in type config.plain"
A Slack notification contains only one attachment. You can add multiple fields though.
receivers:
- name: 'team-X-slack'
slack_configs:
- channel: "#ops"
color: #7CD197
text: "main text"
fields:
- title: "title 1"
value: "can be markup"
- text: "title 2"
value: "more"
If you need several attachments, you can still configure several Slack notifiers in the same receiver.
@jpds the field attachments does not exist, check the link that @simonpasquier provided
It would be great to have multi attachments in the slack_configs. I can't group messages by status (firing/resolved). So I wont to have a possibility to set different colors for firing and resolved alerts in one message.
Most helpful comment
It would be great to have multi attachments in the slack_configs. I can't group messages by status (firing/resolved). So I wont to have a possibility to set different colors for firing and resolved alerts in one message.