Customised slack alerts?

I wonder if anyone has customised their slack alerts?

If so, are you using sensu-slack-handler, or a custom handler?

sensu-slack-handler apparently supports templates, but there is no documentation or examples as to the format of these. I had a skim through the code and the default template appears to just be “{{ .Check.Output }}” which wasn’t any use.

 -t, --descriptionTemplate  The Slack notification output template, in Golang text/template format

By default slack alerts are 6 lines long - I want to condense this to 2 lines.

I also want to be able to include check label and annotation data in the alerts.

Thanks,

Ian

1 Like

The items available to use in the description template are any of the items from the event container. This can include entity or check labels or annotations (though they are exposed outside of the metadata container). For example:

-t '{{.Entity.Labels.Application}} in {{.Entity.Labels.Environment}}'

However, the remaining portions of the Slack message (making it 6 lines) are hardcoded.

1 Like

@ichilton would love your feedback on the existing templating capabilities, as @todd shared above, but we are also always open to improvements.

I know the Slack APIs have changed a LOT since we implemented the Slack handler, so I’m certain there are some cool opportunities to improve the plugin. GitHub issues are super welcome!

2 Likes

@todd Thanks! - I didn’t get around to replying sooner, but I got that working, thanks.

@calebhailey Being able to template the description is part useful, but I need to be able to template the whole message.

The main problem with the stock one is it’s just too big and takes up too much space in the channel so I need to be able to condense it down to just a few lines.

Then there is the requirement to customise the messages differently for each channel (with a separate handler).

Thanks,

Ian