https://github.com/sensu-plugins/sensu-plugins-slack
Sensu Slack chat handlers
https://github.com/sensu-plugins/sensu-plugins-slack
alerting handler notification ruby sensu-plugins slack
Last synced: 2 months ago
JSON representation
Sensu Slack chat handlers
- Host: GitHub
- URL: https://github.com/sensu-plugins/sensu-plugins-slack
- Owner: sensu-plugins
- License: mit
- Created: 2015-02-16T11:30:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T15:04:53.000Z (about 4 years ago)
- Last Synced: 2024-09-20T07:17:38.720Z (9 months ago)
- Topics: alerting, handler, notification, ruby, sensu-plugins, slack
- Language: Ruby
- Homepage: http://sensu-plugins.io
- Size: 118 KB
- Stars: 30
- Watchers: 12
- Forks: 54
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
## Sensu-Plugins-slack
[](https://travis-ci.org/sensu-plugins/sensu-plugins-slack)
[](https://badge.fury.io/rb/sensu-plugins-slack)
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-slack)
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-slack)
[](https://gemnasium.com/sensu-plugins/sensu-plugins-slack)
[](https://slack.sensu.io/badge)## Functionality
## Files
* bin/handler-slack.rb
* bin/handler-slack-multichannel.rb## Usage for handler-slack.rb
```
{
"slack": {
"webhook_url": "webhook url",
"dashboard": "uchiwa url, add link to slack notification. Format: http://sensu.com/#/client/$DataCenter/, optional",
"channel": "#notifications-room, optional defaults to slack defined",
"message_prefix": "optional prefix - can be used for mentions",
"surround": "optional - can be used for bold(*), italics(_), code(`) and preformatted(```)",
"bot_name": "optional bot name, defaults to slack defined",
"link_names": "optional - find and link channel names and usernames",
"message_template": "optional description erb template file - /some/path/to/template.erb",
"payload_template": "optional json payload template file (note: overrides most other template options.)",
"template": "backwards-compatible alias for message_template",
"proxy_address": "The HTTP proxy address (example: proxy.example.com)",
"proxy_port": "The HTTP proxy port (if there is a proxy)",
"proxy_username": "The HTTP proxy username (if there is a proxy)",
"proxy_password": "The HTTP proxy user password (if there is a proxy)",
"icon_url": "https://raw.githubusercontent.com/sensu/sensu-logo/master/sensu1_flat%20white%20bg_png.png",
"icon_emoji": ":snowman:",
"fields": [
"list",
"of",
"optional",
"clientkeys",
"to_render"
]
}
}
```
## Usage for handler-slack-multichannel.rb
```
{
"slack": {
"webhook_urls": {
"no-team-alerts": "https://hooks.slack.com/services/AAAAAAA",
"all-alerts": "https://hooks.slack.com/services/BBBBBB"
},
"channels": {
"default": [ "no-team-alerts" ],
"compulsory": [ "all-alerts" ]
}
"message_prefix": "optional prefix - can be used for mentions",
"surround": "optional - can be used for bold(*), italics(_), code(`) and preformatted(```)",
"bot_name": "optional bot name, defaults to slack defined",
"link_names": "optional - find and link channel names and usernames",
"message_template": "optional description erb template file - /some/path/to/template.erb",
"payload_template": "optional json payload template file (note: overrides most other template options.)",
"template": "backwards-compatible alias for message_template",
"proxy_address": "The HTTP proxy address (example: proxy.example.com)",
"proxy_port": "The HTTP proxy port (if there is a proxy)",
"proxy_username": "The HTTP proxy username (if there is a proxy)",
"proxy_password": "The HTTP proxy user password (if there is a proxy)",
"icon_url": "https://raw.githubusercontent.com/sensu/sensu-logo/master/sensu1_flat%20white%20bg_png.png",
"icon_emoji": ":snowman:",
"custom_field": [
"list",
"of",
"optional",
"check_fields",
"to_render"
]
}
}
```## Installation
[Installation and Setup](https://sensu-plugins.io/docs/installation_instructions.html)
## Notes
### payload_template example
```
{
"username": "sensu alarms",
"icon_emoji": ":bell:",
"channel": channel,
"attachments": [
{
"fallback": "<%= @event["check"]["output"].gsub('"', '\\"') %>",
"color": "<%= color %>",
"title": "<%= @event["check"]["name"] %> (<%= @event["client"]["name"] %>)",
"text": "<%= @event["check"]["output"].gsub('"', '\\"') %>"
}
]
}
```You can also use `to_json`
```
<%=
{
:text => "Some text"
}.to_json
-%>
```See https://api.slack.com/incoming-webhooks and https://api.slack.com/docs/attachments