5

I have Sensu running and followed the instructions the best I could to install the Slack plugin. I'm attempting to just do a "hello-world" to get started, but the documentation seems lacking to me.

I followed the "getting started" with checks: https://sensuapp.org/docs/0.20/getting-started-with-checks and everything seems to be in the correct place on the server.

I am attempting to install the following community plugin, but they have a catch-all instruction for all community plugins. There is a json file in the plugin instructions, but doesn't say where to put it... https://github.com/sensu-plugins/sensu-plugins-slack

Here is what my check_cron.json looks like ( I tried 2 methods, 1 from another source other than Sensu):

{
    "checks": {
      "cron_checks": {
        "handlers": ["default", "slack"],
        "command": "/etc/sensu/plugins/check-procs.rb -p cron -C 1 ",
        "interval": 60,      "subscribers": ["webservers"]
      },
      "cron": {
        "handlers": ["default", "slack"],
        "command": "/etc/sensu/plugins/check-procs.rb -p cron",
        "subscribers": [
            "production",
            "webservers",
        ],
        "interval": 60
      }
    }
  }

I have restarted my server after making the changes. I'm assuming that this cron will hit every minute and call the slack notification plugin, but don't know what I'm missing, or where to put the .json doc from the Slack plugin "documentation" https://github.com/sensu-plugins/sensu-plugins-slack

Any help getting me to the right direction?

benishky
  • 901
  • 1
  • 11
  • 23

4 Answers4

0

You need a handler on the Sensu Server that will fire the request to Slack. Have you created that? If yes, please post it's content.

Dennis Winter
  • 2,027
  • 4
  • 32
  • 45
0

So I just solved this. benishkey did provide the solution in the link, however, just in case anyone comes across this and the link is broken, I thought I would add the solution.

-github user eugene-chow:

The Slack handler's config need to be named differently. Try the JSON below. I renamed the Slack config for each environment, and then pointed the handler to the respective config with -j config_name

{
  "handlers": {
    "slack-staging": {
      "type": "pipe",
      "command": "/usr/local/bin/handler-slack.rb -j slack-staging",
      "severites": ["critical", "unknown"]
    }
  },
  "slack-staging": {
    "webhook_url": "https://hooks.slack.com/services/...",
    "template" : ""
  }
}


{
  "handlers": {
    "slack-production": {
      "type": "pipe",
      "command": "/usr/local/bin/handler-slack.rb -j slack-production",
      "severites": ["critical", "unknown"]
    }
  },
  "slack-production": {
    "webhook_url": "https://hooks.slack.com/services/...",
    "template" : ""
  }
}

I dropped the handler-slack.rb file in with my checks and referenced it from there because it wasn't in my /usr/local/bin/ folder

Community
  • 1
  • 1
Electronicks
  • 13
  • 2
  • 6
0

I was facing the same issue, so the answer is already given but maybe help someone in the future,

First, install sensu slack plugin

/opt/sensu/embedded/bin/gem install sensu-plugins-slack

Then, Create a handler config file

   vim /etc/sensu/conf.d/slack-handler.json

handler-slack.rb https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack.rb

{
    "handlers": {
        "slack": {
            "type": "pipe",
            "command": "/opt/sensu/embedded/bin/handler-slack.rb",
            "severites": ["critical", "unknown"]
        }
    },
    "slack": {
        "webhook_url": "https://your_webhook.com/abc",
        "template" : ""
    }
}  
Adiii
  • 54,482
  • 7
  • 145
  • 148
-1

I found the answer in the "issues" section in Git https://github.com/sensu-plugins/sensu-plugins-slack/issues/7

benishky
  • 901
  • 1
  • 11
  • 23