added support for proxy into slack plugin, removed some sensitive information from message
Change-Id: I071b74eac9b805380ba4f92cdad2c9f2f84f04d4
diff --git a/sensu/files/handlers/slack.json b/sensu/files/handlers/slack.json
index 2ec633c..c12adfb 100644
--- a/sensu/files/handlers/slack.json
+++ b/sensu/files/handlers/slack.json
@@ -23,6 +23,12 @@
"slack": {
"webhook_url": "{{ handler.webhook_url }}",
"channel": "{{ handler.channel }}",
+ {%- if handler.proxy_address is defined %}
+ "proxy_addr": "{{ handler.proxy_address }}",
+ {%- endif %}
+ {%- if handler.proxy_port is defined %}
+ "proxy_port": "{{ handler.proxy_port }}",
+ {%- endif %}
"markdown_enabled": false
}
}
diff --git a/sensu/files/plugins/handlers/notification/slack.rb b/sensu/files/plugins/handlers/notification/slack.rb
index b80c7d0..32343cf 100644
--- a/sensu/files/plugins/handlers/notification/slack.rb
+++ b/sensu/files/plugins/handlers/notification/slack.rb
@@ -57,20 +57,30 @@
@event['client']['name'] + '/' + @event['check']['name']
end
+ def incident_host
+ @event['client']['name']
+ end
+
+ def incident_check
+ @event['check']['name']
+ end
+
+ def incident_ip
+ @event['client']['address']
+ end
+
def get_setting(name)
settings[config[:json_config]][name]
end
def handle
description = @event['check']['notification'] || build_description
- post_data("*Check*\n#{incident_key}\n\n*Description*\n#{description}")
+ post_data("*Host*: #{incident_host} \n\n*Check*: #{incident_check}\n#{description}")
end
def build_description
[
@event['check']['output'].strip,
- @event['client']['address'],
- @event['client']['subscriptions'].join(',')
].join(' : ')
end