Install Slack Plugin for Sensu Custom Version

Sensu works for me and follow the instructions that I could install for the Slack plugin. I'm trying to just do a hi-world to get started, but it seems to me that I am missing documentation.

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

I am trying to install the following community plugin, but they have a catch-all command for all community plugins. There is a json file in the instructions of the plugin, but it does not say where to put it ... https://github.com/sensu-plugins/sensu-plugins-slack

This is what my check_cron.json looks like (I tried 2 methods, 1 from a 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 restarted my server after making the changes. I assume that this cron will beat every minute and call the slack notification plugin, but I don’t know what I am missing or where to put the .json document from the Slack plugin “documentation”, https://github.com/sensu -plugins / sensu-plugins-slack

Any help help me in the right direction?

+5
source share
4 answers

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

-1
source

You need a handler on the Sensu server that will run the request to Slack. Did you create this? If so, submit it for content.

0
source

So I just decided it. benishkey did provide a solution to the link , however, just in case someone encounters this, and the link is broken, I thought I would add a solution.

-github user eugene-chow:

The configuration of the Slack handler must be named differently. Try JSON below. I renamed the Slack configuration for each environment, and then pointed the handler to the appropriate configuration using -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 dumped the handler-slack.rb with my checks and typed it there because it was not in my /usr/local/bin/

0
source

I ran into the same problem, so the answer is already given, but maybe I will help someone in the future,

First install the Senseu Slack plugin

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

Then create a handler configuration 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" : "" } } 
0
source

Source: https://habr.com/ru/post/1234294/


All Articles