Sensu Slack chat handlers
Ruby
Pull request Compare This branch is 4 commits behind sensu-plugins:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
bin
certs
lib
test
.gitignore
.rubocop.yml
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Gemfile
LICENSE
README.md
Rakefile
sensu-plugins-slack.gemspec

README.md

Sensu-Plugins-slack

Build Status Gem Version Code Climate Test Coverage Dependency Status

Functionality

Files

  • bin/handler-slack.rb
  • bin/handler-slack-multichannel.rb

Usage

{
  "slack": {
    "webhook_url": "webhook url",
    "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",
    "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": "http://sensuapp.org/img/sensu_logo_large-c92d73db.png",
    "icon_emoji": ":snowman:",
    "fields": [
      "list",
      "of",
      "optional",
      "clientkeys",
      "to_render"
    ]
  }
}

Installation

Installation and Setup

Notes

payload_template example

{
  "username": "sensu alarms",
  "icon_emoji": ":bell:",
  "attachments": [
    {
      "fallback": "<%= @event["check"]["output"] %>",
      "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