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

Enable default webhook in multichannel handler #95

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins

## [Unreleased]

## [4.2.0]- 2019-10-08
### Added
- `handler-slack-multichannel.rb`: Added a conditional that enables sending to a default webhook if the provided channels do not have their own dedicated webhook.

## [4.1.0]- 2019-05-16
### Added
- `handler-slack`: added `webhook_retries` (default: 5), `webhook_timeout` (default: 10), and `webhook_retry_sleep` configuration properties to harden against failures due to networking, rate limits, etc. (@kali-brandwatch)
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
{
"slack": {
"webhook_urls": {
"no-team-alerts": "https://hooks.slack.com/services/AAAAAAA",
"all-alerts": "https://hooks.slack.com/services/BBBBBB"
"default": "https://hooks.slack.com/services/AAAAAAA"
"no-team-alerts": "https://hooks.slack.com/services/BBBBBB",
"all-alerts": "https://hooks.slack.com/services/CCCCCC"
},
"channels": {
"default": [ "no-team-alerts" ],
Expand Down
7 changes: 6 additions & 1 deletion bin/handler-slack-multichannel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ def build_description
end

def post_data(notice, channel)
slack_webhook_url = webhook_urls[channel]
slack_webhook_url = if webhook_urls[channel].nil?
webhook_urls['default']
else
webhook_urls[channel]
end

uri = URI(slack_webhook_url)

http = if defined?(slack_proxy_addr).nil?
Expand Down