Which check result variables are passed into Sensu Enterprise's built-in Slack integration template, and how can I use them?

enterprise

#1

I am interested in designing my own Slack message template for the built-in Enterprise Slack integration.

https://docs.sensu.io/sensu-enterprise/3.2/integrations/slack/#templates-attributes

I do not see any information or examples on how this template works, and what variables I can expect to be able to use within the template.

Any information would be very helpful regarding the usage of the Slack template in the context of Sensu results that I want to inject into the message.


#2

Hi there :wave:!

The email integration documentation actually has a useful template for seeing what gets exposed. One that I’ve recommended to folks in the past is something like this:

Sensu has detected a status change of a check.  Please note the following details:

Client: <%= @event["client"]["name"] %>

Check: <%= @event["check"]["name"] %>

Output: <%= @event["check"]["output"] %>

Status: <%= @event["check"]["status"] %> -- (0 = OK, 1 = Warning, 2 = Critical.  Any other number = unknown or a custom status)

<% if @event["check"].key?("notification") %>
Instructions (if there is a problem - check output section): <%= @event["check"]["notification"] \r\n %>
<% else %>
Aaron's 1st Test Statement \r\n
<% end %>

For more information, please consult the Sensu Enterprise dashboard:

<% if @event["client"].key?("datacenter") %>
http://$DASHBOARDURL:3000/#/client/<%= @event["client"]["datacenter"] %>/<%= @event["client"]["name"] %>?check=<%= @event["check"]["name"] %>
<% else %>
Aaron's 2nd Test Statement
<% end %>

Keep in mind that this was used for the MS teams community plugin, but the effect should be the same. Let me know if this helps!


#3

The Events reference documentation page has an example event data payload that you can use as a reference for what attributes are available by default. Keep in mind that any custom check definition or client definition attributes you have set will also be available at their corresponding @event["check"]["foo"] and @event["client"]["foo"] paths.

Hope this helps!