sensu-plugins / sensu-plugins-slack

Sensu Slack chat handlers
http://sensu-plugins.io
MIT License
30 stars 54 forks source link

Documentation for open source Slack alternative Mattermost #28

Open LukeFlynn opened 7 years ago

LukeFlynn commented 7 years ago

Hello!

My team recently migrated from Slack to Mattermost. Mattermost has support for quite a few Slack webhooks already, this one doesn't seem to work though. Is there anyways support could be implemented.. or a way I could hack this together to work?

{"timestamp":"2016-08-25T22:01:35.778237-0500","level":"info","message":"handler output","handler":{"command":"/opt/sensu/embedded/bin/handler-slack.rb","type":"pipe","severities":["critical","unknown"],"name":"slack"},"output":["/opt/sensu/embedded/lib/ruby/2.3.0/net/http/response.rb:120:in `error!': 500 \"Internal Server Error\" (Net::HTTPFatalError)\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-slack-1.0.0/bin/handler-slack.rb:149:in `verify_response'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-slack-1.0.0/bin/handler-slack.rb:141:in `post_data'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-slack-1.0.0/bin/handler-slack.rb:92:in `handle'\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.3.0/lib/sensu-handler.rb:57:in `block in <class:Handler>'\n"]}

I understand if this is not possible, being that your primary focus is obviously Slack. If there's nothing you guys can do about, is it possible to make a suggestion for a new plugin that does this?

Thanks.

rahulsh1 commented 7 years ago

I was able to get this working with Mattermost. See #7 for more details on how to configure the slack plugin.

lcx commented 5 years ago

for me it only it worked only after adding the content type to the post request.

req = Net::HTTP::Post.new("#{uri.path}?#{uri.query}", 'Content-Type' => 'application/json')

I should check if this works with slack as well, it might make sense to add it even for the non mattermost users?

joostfaassen commented 5 years ago

This plugin seems to be correctly sending the content-type since this commit in december 2015:

https://github.com/sensu-plugins/sensu-plugins-slack/blame/master/bin/handler-slack.rb#L152

I can also confirm this plugin works well with Mattermost, here's an example config:

{
  "slack": {
    "webhook_url": "https://mattermost.example.com/hooks/xxxxx-xxxxx-xxxxx-xxxxx",
    "dashboard": "https://uchiwa.example.com/#/client/my-datacenter/",
    "channel": "my-channel-name",
    "bot_name": "sensu",
    "icon_url": "https://raw.githubusercontent.com/sensu/sensu-logo/master/sensu1_flat%20white%20bg_png.png",
    "message_prefix": "@user-x, @user-y "
  }
}

Note that you'll need #71 in order for the notifications based on the message_prefix to work though.