# Struggling to get slack report to two different channels

**URL:** <https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771>\
**Category:** Sensu Classic (EOL)\
**Created:** [February 23, 2017, 3:09am UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771 "2017-02-23T03:09:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![aiman\_parvaiz1](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@aiman\_parvaiz1](https://discourse.sensu.io/u/aiman_parvaiz1)\
**Post date:** [February 23, 2017, 3:09am UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/1 "2017-02-23T03:09:45Z")

</div>

Hi all  
I am trying to get certain alerts to one slack channel and rest to a separate one. I am using sensu 0.26.5. I have two json files for handlers in /etc/sensu/conf.d

1. cops\_slack.json

{

“handlers”: {

“cops\_slack”: {

“type”: “pipe”,

“command”: “/etc/sensu/handlers/cops\_slack.rb”

}

},

“slack”: {

“webhook\_url”:"[https://hooks.slack.com/services/XXXDDDD](https://hooks.slack.com/services/XXXDDDD),

“channel”: “#alerts1”,

“bot\_name”: “Sensu”,

“markdown\_enabled”: true

}

}

1. my\_handler.json

{

“handlers”: {

“slack”: {

“type”: “pipe”,

“command”: “/etc/sensu/handlers/my\_handler\_slack.rb”

}

},

“slack”: {

“webhook\_url”: “[https://hooks.slack.com/services/XXX](https://hooks.slack.com/services/XXX)”,

“channel”: “#backend-core-alerts”,

“bot\_name”: “Sensu”,

“markdown\_enabled”: true

}

}

I am specifying handler to use in the check definition, for example:

{

“checks”: {

“cassandra\_ntp”: {

“handler”: “cops\_slack”,

“command”: “check-process.rb -p ntp -W 1”,

“subscribers”: [

“ABCD”

],

“interval”: 60

}

}

}

This setup is not working for me. For some strange reasons if I remove my\_handler.json from conf.d/ cops\_slack handler would kick in as expected and would report to the expected channel but as soon as I bring back my\_handler (restart sensu server, api) the same check now would report to the channel mentioned in my\_handler. I have reproduced this several times and am out of ideas here. I would be grateful if some one can help me out here.

Thanks

---

<div class="post-metadata">

**Author:** ![Kyle\_Anderson](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@Kyle\_Anderson](https://discourse.sensu.io/u/Kyle_Anderson)\
**Post date:** [February 23, 2017, 4:48am UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/2 "2017-02-23T04:48:06Z")

</div>

All the json files in conf.d get merged together, so there is only one “slack”: configuration hash manifesting.

You will probably have to do something that understands multi-channel more natively

[https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb](https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb)

> **···**
>
> On Wed, Feb 22, 2017 at 7:09 PM, aiman parvaiz [aimanparvaiz@gmail.com](mailto:aimanparvaiz@gmail.com) wrote:
> 
> > Hi all  
> > I am trying to get certain alerts to one slack channel and rest to a separate one. I am using sensu 0.26.5. I have two json files for handlers in /etc/sensu/conf.d
> 
> > 
> 
> > 1. cops\_slack.json
> 
> > 
> 
> > {
> 
> > “handlers”: {
> 
> > “cops\_slack”: {
> 
> > “type”: “pipe”,
> 
> > “command”: “/etc/sensu/handlers/cops\_slack.rb”
> 
> > }
> 
> > },
> 
> > “slack”: {
> 
> > “webhook\_url”:"[https://hooks.slack.com/services/XXXDDDD](https://hooks.slack.com/services/XXXDDDD),
> 
> > “channel”: “#alerts1”,
> 
> > “bot\_name”: “Sensu”,
> 
> > “markdown\_enabled”: true
> 
> > }
> 
> > }
> 
> > 
> 
> > 
> 
> > 1. my\_handler.json
> 
> > 
> 
> > {
> 
> > “handlers”: {
> 
> > “slack”: {
> 
> > “type”: “pipe”,
> 
> > “command”: “/etc/sensu/handlers/my\_handler\_slack.rb”
> 
> > }
> 
> > },
> 
> > “slack”: {
> 
> > “webhook\_url”: “[https://hooks.slack.com/services/XXX](https://hooks.slack.com/services/XXX)”,
> 
> > “channel”: “#backend-core-alerts”,
> 
> > “bot\_name”: “Sensu”,
> 
> > “markdown\_enabled”: true
> 
> > }
> 
> > }
> 
> > 
> 
> > I am specifying handler to use in the check definition, for example:
> 
> > 
> 
> > {
> 
> > “checks”: {
> 
> > “cassandra\_ntp”: {
> 
> > “handler”: “cops\_slack”,
> 
> > “command”: “check-process.rb -p ntp -W 1”,
> 
> > “subscribers”: [
> 
> > “ABCD”
> 
> > ],
> 
> > “interval”: 60
> 
> > }
> 
> > }
> 
> > }
> 
> > 
> 
> > This setup is not working for me. For some strange reasons if I remove my\_handler.json from conf.d/ cops\_slack handler would kick in as expected and would report to the expected channel but as soon as I bring back my\_handler (restart sensu server, api) the same check now would report to the channel mentioned in my\_handler. I have reproduced this several times and am out of ideas here. I would be grateful if some one can help me out here.
> 
> > 
> 
> > Thanks

---

<div class="post-metadata">

**Author:** ![aiman\_parvaiz1](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@aiman\_parvaiz1](https://discourse.sensu.io/u/aiman_parvaiz1)\
**Post date:** [February 23, 2017, 5:55am UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/3 "2017-02-23T05:55:46Z")

</div>

Aahh that would explain the behavior. Thanks Kyle for this pointer, I will look in to slack-multichannel.

> **···**
>
> On Wednesday, February 22, 2017 at 8:48:08 PM UTC-8, Kyle Anderson wrote:
> 
> > All the json files in conf.d get merged together, so there is only one “slack”: configuration hash manifesting.
> 
> > You will probably have to do something that understands multi-channel more natively
> 
> > [https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb](https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fsensu-plugins%2Fsensu-plugins-slack%2Fblob%2Fmaster%2Fbin%2Fhandler-slack-multichannel.rb&sa=D&sntz=1&usg=AFQjCNHAYCAtaDvyUgkTZhqwLkXxRrpSdQ)
> 
> > 
> 
> > 
> 
> > On Wed, Feb 22, 2017 at 7:09 PM, aiman parvaiz [aimanp...@gmail.com](mailto:aimanp...@gmail.com) wrote:
> > 
> > > Hi all  
> > > I am trying to get certain alerts to one slack channel and rest to a separate one. I am using sensu 0.26.5. I have two json files for handlers in /etc/sensu/conf.d
> 
> > >
> 
> > > 1. cops\_slack.json
> 
> > >
> 
> > > {
> 
> > > “handlers”: {
> 
> > > “cops\_slack”: {
> 
> > > “type”: “pipe”,
> 
> > > “command”: “/etc/sensu/handlers/cops\_slack.rb”
> 
> > > }
> 
> > > },
> 
> > > “slack”: {
> 
> > > “webhook\_url”:"[https://hooks.slack.com/services/XXXDDDD](https://hooks.slack.com/services/XXXDDDD),
> 
> > > “channel”: “#alerts1”,
> 
> > > “bot\_name”: “Sensu”,
> 
> > > “markdown\_enabled”: true
> 
> > > }
> 
> > > }
> 
> > >
> 
> > >
> 
> > > 1. my\_handler.json
> 
> > >
> 
> > > {
> 
> > > “handlers”: {
> 
> > > “slack”: {
> 
> > > “type”: “pipe”,
> 
> > > “command”: “/etc/sensu/handlers/my\_handler\_slack.rb”
> 
> > > }
> 
> > > },
> 
> > > “slack”: {
> 
> > > “webhook\_url”: “[https://hooks.slack.com/services/XXX](https://hooks.slack.com/services/XXX)”,
> 
> > > “channel”: “#backend-core-alerts”,
> 
> > > “bot\_name”: “Sensu”,
> 
> > > “markdown\_enabled”: true
> 
> > > }
> 
> > > }
> 
> > >
> 
> > > I am specifying handler to use in the check definition, for example:
> 
> > >
> 
> > > {
> 
> > > “checks”: {
> 
> > > “cassandra\_ntp”: {
> 
> > > “handler”: “cops\_slack”,
> 
> > > “command”: “check-process.rb -p ntp -W 1”,
> 
> > > “subscribers”: [
> 
> > > “ABCD”
> 
> > > ],
> 
> > > “interval”: 60
> 
> > > }
> 
> > > }
> 
> > > }
> 
> > >
> 
> > > This setup is not working for me. For some strange reasons if I remove my\_handler.json from conf.d/ cops\_slack handler would kick in as expected and would report to the expected channel but as soon as I bring back my\_handler (restart sensu server, api) the same check now would report to the channel mentioned in my\_handler. I have reproduced this several times and am out of ideas here. I would be grateful if some one can help me out here.
> 
> > >
> 
> > > Thanks
> 
> >

---

<div class="post-metadata">

**Author:** ![David\_R](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@David\_R](https://discourse.sensu.io/u/David_R)\
**Post date:** [April 20, 2017, 12:21pm UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/4 "2017-04-20T12:21:21Z")

</div>

The documentation embedded into the source for the handler-slack-multichannel is a bit sparse. Any ideas on how one would define the various channels? For the basic slack module, one has to define a webhook\_url. Presumably, with the multichannel plugin, one would have a list of webhook\_urls to define for the various channels (default, compulsory, etc). I’ve tried a few variations on my own, but to no avail. Any guidance would be most appreciated!

> **···**
>
> On Wednesday, February 22, 2017 at 11:48:08 PM UTC-5, Kyle Anderson wrote:
> 
> > All the json files in conf.d get merged together, so there is only one “slack”: configuration hash manifesting.
> 
> > You will probably have to do something that understands multi-channel more natively
> 
> > [https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb](https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb)
> 
> > 
> 
> > 
> 
> > On Wed, Feb 22, 2017 at 7:09 PM, aiman parvaiz [aimanp...@gmail.com](mailto:aimanp...@gmail.com) wrote:
> > 
> > > Hi all  
> > > I am trying to get certain alerts to one slack channel and rest to a separate one. I am using sensu 0.26.5. I have two json files for handlers in /etc/sensu/conf.d
> 
> > >
> 
> > > 1. cops\_slack.json
> 
> > >
> 
> > > {
> 
> > > “handlers”: {
> 
> > > “cops\_slack”: {
> 
> > > “type”: “pipe”,
> 
> > > “command”: “/etc/sensu/handlers/cops\_slack.rb”
> 
> > > }
> 
> > > },
> 
> > > “slack”: {
> 
> > > “webhook\_url”:"[https://hooks.slack.com/services/XXXDDDD](https://hooks.slack.com/services/XXXDDDD),
> 
> > > “channel”: “#alerts1”,
> 
> > > “bot\_name”: “Sensu”,
> 
> > > “markdown\_enabled”: true
> 
> > > }
> 
> > > }
> 
> > >
> 
> > >
> 
> > > 1. my\_handler.json
> 
> > >
> 
> > > {
> 
> > > “handlers”: {
> 
> > > “slack”: {
> 
> > > “type”: “pipe”,
> 
> > > “command”: “/etc/sensu/handlers/my\_handler\_slack.rb”
> 
> > > }
> 
> > > },
> 
> > > “slack”: {
> 
> > > “webhook\_url”: “[https://hooks.slack.com/services/XXX](https://hooks.slack.com/services/XXX)”,
> 
> > > “channel”: “#backend-core-alerts”,
> 
> > > “bot\_name”: “Sensu”,
> 
> > > “markdown\_enabled”: true
> 
> > > }
> 
> > > }
> 
> > >
> 
> > > I am specifying handler to use in the check definition, for example:
> 
> > >
> 
> > > {
> 
> > > “checks”: {
> 
> > > “cassandra\_ntp”: {
> 
> > > “handler”: “cops\_slack”,
> 
> > > “command”: “check-process.rb -p ntp -W 1”,
> 
> > > “subscribers”: [
> 
> > > “ABCD”
> 
> > > ],
> 
> > > “interval”: 60
> 
> > > }
> 
> > > }
> 
> > > }
> 
> > >
> 
> > > This setup is not working for me. For some strange reasons if I remove my\_handler.json from conf.d/ cops\_slack handler would kick in as expected and would report to the expected channel but as soon as I bring back my\_handler (restart sensu server, api) the same check now would report to the channel mentioned in my\_handler. I have reproduced this several times and am out of ideas here. I would be grateful if some one can help me out here.
> 
> > >
> 
> > > Thanks
> 
> >

---

<div class="post-metadata">

**Author:** ![aiman\_parvaiz1](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@aiman\_parvaiz1](https://discourse.sensu.io/u/aiman_parvaiz1)\
**Post date:** [April 25, 2017, 5:24pm UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/5 "2017-04-25T17:24:10Z")

</div>

Hey David  
The way I got it working is as follows:

I am using multichannel\_slack.rb and I have it’s json file in the conf.d directory, this is the content of that file:

{

“handlers”: {

“multi\_slack”: {

“channels”: {

“default”: [“#alerts”]

},

“type”: “pipe”,

“command”: “/etc/sensu/handlers/multichannel\_slack.rb”

}

},

“slack”: {

“webhook\_url”:“[Unlock your productivity potential with Slack Platform | Slack](https://hooks.slack.com/asdervsdft)”,

“channel”: “#alerts”,

“bot\_name”: “Sensu”,

“markdown\_enabled”: true

}

}

All alerts by default go to #alerts, in cases where I want to report to some other channel I include the channel name in the json of the check, for example:

{

“checks”: {

“cassandra\_check”: {

“command”: “check-process.rb -p cassandra -C 1 -x ‘.log$’”,

“handler”:“multi\_slack”,

“subscribers”: [

“cassandra”,

],

“slack”: {

“channels”:[“#cops-alerts”]

},

“interval”: 60

}

}

}

and this way I am able to get alerts sent to various channels, my requirement was to send the alert to any one of the channels depending on the check and this solution works for that case.

I hope this helps.

Thanks

> **···**
>
> On Thursday, April 20, 2017 at 5:21:21 AM UTC-7, David R wrote:
> 
> > The documentation embedded into the source for the handler-slack-multichannel is a bit sparse. Any ideas on how one would define the various channels? For the basic slack module, one has to define a webhook\_url. Presumably, with the multichannel plugin, one would have a list of webhook\_urls to define for the various channels (default, compulsory, etc). I’ve tried a few variations on my own, but to no avail. Any guidance would be most appreciated!
> > 
> > On Wednesday, February 22, 2017 at 11:48:08 PM UTC-5, Kyle Anderson wrote:
> > 
> > > All the json files in conf.d get merged together, so there is only one “slack”: configuration hash manifesting.
> 
> > > You will probably have to do something that understands multi-channel more natively
> 
> > > [https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb](https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb)
> 
> > >
> 
> > >
> 
> > > On Wed, Feb 22, 2017 at 7:09 PM, aiman parvaiz [aimanp...@gmail.com](mailto:aimanp...@gmail.com) wrote:
> > > 
> > > > Hi all  
> > > > I am trying to get certain alerts to one slack channel and rest to a separate one. I am using sensu 0.26.5. I have two json files for handlers in /etc/sensu/conf.d
> 
> > > >
> 
> > > > 1. cops\_slack.json
> 
> > > >
> 
> > > > {
> 
> > > > “handlers”: {
> 
> > > > “cops\_slack”: {
> 
> > > > “type”: “pipe”,
> 
> > > > “command”: “/etc/sensu/handlers/cops\_slack.rb”
> 
> > > > }
> 
> > > > },
> 
> > > > “slack”: {
> 
> > > > “webhook\_url”:"[https://hooks.slack.com/services/XXXDDDD](https://hooks.slack.com/services/XXXDDDD),
> 
> > > > “channel”: “#alerts1”,
> 
> > > > “bot\_name”: “Sensu”,
> 
> > > > “markdown\_enabled”: true
> 
> > > > }
> 
> > > > }
> 
> > > >
> 
> > > >
> 
> > > > 1. my\_handler.json
> 
> > > >
> 
> > > > {
> 
> > > > “handlers”: {
> 
> > > > “slack”: {
> 
> > > > “type”: “pipe”,
> 
> > > > “command”: “/etc/sensu/handlers/my\_handler\_slack.rb”
> 
> > > > }
> 
> > > > },
> 
> > > > “slack”: {
> 
> > > > “webhook\_url”: “[https://hooks.slack.com/services/XXX](https://hooks.slack.com/services/XXX)”,
> 
> > > > “channel”: “#backend-core-alerts”,
> 
> > > > “bot\_name”: “Sensu”,
> 
> > > > “markdown\_enabled”: true
> 
> > > > }
> 
> > > > }
> 
> > > >
> 
> > > > I am specifying handler to use in the check definition, for example:
> 
> > > >
> 
> > > > {
> 
> > > > “checks”: {
> 
> > > > “cassandra\_ntp”: {
> 
> > > > “handler”: “cops\_slack”,
> 
> > > > “command”: “check-process.rb -p ntp -W 1”,
> 
> > > > “subscribers”: [
> 
> > > > “ABCD”
> 
> > > > ],
> 
> > > > “interval”: 60
> 
> > > > }
> 
> > > > }
> 
> > > > }
> 
> > > >
> 
> > > > This setup is not working for me. For some strange reasons if I remove my\_handler.json from conf.d/ cops\_slack handler would kick in as expected and would report to the expected channel but as soon as I bring back my\_handler (restart sensu server, api) the same check now would report to the channel mentioned in my\_handler. I have reproduced this several times and am out of ideas here. I would be grateful if some one can help me out here.
> 
> > > >
> 
> > > > Thanks
> 
> > >

---

<div class="post-metadata">

**Author:** ![David\_R](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@David\_R](https://discourse.sensu.io/u/David_R)\
**Post date:** [April 25, 2017, 6:16pm UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/6 "2017-04-25T18:16:46Z")

</div>

Hey, Aiman,

This is immensely helpful; thank you!

David

> **···**
>
> On Tuesday, April 25, 2017 at 1:24:10 PM UTC-4, aiman parvaiz wrote:
> 
> > Hey David  
> > The way I got it working is as follows:
> 
> > I am using multichannel\_slack.rb and I have it’s json file in the conf.d directory, this is the content of that file:
> 
> > 
> 
> > 
> 
> > {
> 
> > “handlers”: {
> 
> > “multi\_slack”: {
> 
> > “channels”: {
> 
> > “default”: [“#alerts”]
> 
> > },
> 
> > “type”: “pipe”,
> 
> > “command”: “/etc/sensu/handlers/multichannel\_slack.rb”
> 
> > }
> 
> > },
> 
> > “slack”: {
> 
> > “webhook\_url”:“[https://hooks.slack.com/asdervsdft](https://hooks.slack.com/asdervsdft)”,
> 
> > “channel”: “#alerts”,
> 
> > “bot\_name”: “Sensu”,
> 
> > “markdown\_enabled”: true
> 
> > }
> 
> > }
> 
> > All alerts by default go to #alerts, in cases where I want to report to some other channel I include the channel name in the json of the check, for example:
> 
> > 
> 
> > {
> 
> > “checks”: {
> 
> > “cassandra\_check”: {
> 
> > “command”: “check-process.rb -p cassandra -C 1 -x ‘.log$’”,
> 
> > “handler”:“multi\_slack”,
> 
> > “subscribers”: [
> 
> > “cassandra”,
> 
> > ],
> 
> > “slack”: {
> 
> > “channels”:[“#cops-alerts”]
> 
> > },
> 
> > “interval”: 60
> 
> > }
> 
> > }
> 
> > }
> 
> > and this way I am able to get alerts sent to various channels, my requirement was to send the alert to any one of the channels depending on the check and this solution works for that case.
> 
> > I hope this helps.
> 
> > Thanks
> 
> > 
> 
> > On Thursday, April 20, 2017 at 5:21:21 AM UTC-7, David R wrote:
> > 
> > > The documentation embedded into the source for the handler-slack-multichannel is a bit sparse. Any ideas on how one would define the various channels? For the basic slack module, one has to define a webhook\_url. Presumably, with the multichannel plugin, one would have a list of webhook\_urls to define for the various channels (default, compulsory, etc). I’ve tried a few variations on my own, but to no avail. Any guidance would be most appreciated!
> > > 
> > > On Wednesday, February 22, 2017 at 11:48:08 PM UTC-5, Kyle Anderson wrote:
> > > 
> > > > All the json files in conf.d get merged together, so there is only one “slack”: configuration hash manifesting.
> 
> > > > You will probably have to do something that understands multi-channel more natively
> 
> > > > [https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb](https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb)
> 
> > > >
> 
> > > >
> 
> > > > On Wed, Feb 22, 2017 at 7:09 PM, aiman parvaiz [aimanp...@gmail.com](mailto:aimanp...@gmail.com) wrote:
> > > > 
> > > > > Hi all  
> > > > > I am trying to get certain alerts to one slack channel and rest to a separate one. I am using sensu 0.26.5. I have two json files for handlers in /etc/sensu/conf.d
> 
> > > > >
> 
> > > > > 1. cops\_slack.json
> 
> > > > >
> 
> > > > > {
> 
> > > > > “handlers”: {
> 
> > > > > “cops\_slack”: {
> 
> > > > > “type”: “pipe”,
> 
> > > > > “command”: “/etc/sensu/handlers/cops\_slack.rb”
> 
> > > > > }
> 
> > > > > },
> 
> > > > > “slack”: {
> 
> > > > > “webhook\_url”:"[https://hooks.slack.com/services/XXXDDDD](https://hooks.slack.com/services/XXXDDDD),
> 
> > > > > “channel”: “#alerts1”,
> 
> > > > > “bot\_name”: “Sensu”,
> 
> > > > > “markdown\_enabled”: true
> 
> > > > > }
> 
> > > > > }
> 
> > > > >
> 
> > > > >
> 
> > > > > 1. my\_handler.json
> 
> > > > >
> 
> > > > > {
> 
> > > > > “handlers”: {
> 
> > > > > “slack”: {
> 
> > > > > “type”: “pipe”,
> 
> > > > > “command”: “/etc/sensu/handlers/my\_handler\_slack.rb”
> 
> > > > > }
> 
> > > > > },
> 
> > > > > “slack”: {
> 
> > > > > “webhook\_url”: “[https://hooks.slack.com/services/XXX](https://hooks.slack.com/services/XXX)”,
> 
> > > > > “channel”: “#backend-core-alerts”,
> 
> > > > > “bot\_name”: “Sensu”,
> 
> > > > > “markdown\_enabled”: true
> 
> > > > > }
> 
> > > > > }
> 
> > > > >
> 
> > > > > I am specifying handler to use in the check definition, for example:
> 
> > > > >
> 
> > > > > {
> 
> > > > > “checks”: {
> 
> > > > > “cassandra\_ntp”: {
> 
> > > > > “handler”: “cops\_slack”,
> 
> > > > > “command”: “check-process.rb -p ntp -W 1”,
> 
> > > > > “subscribers”: [
> 
> > > > > “ABCD”
> 
> > > > > ],
> 
> > > > > “interval”: 60
> 
> > > > > }
> 
> > > > > }
> 
> > > > > }
> 
> > > > >
> 
> > > > > This setup is not working for me. For some strange reasons if I remove my\_handler.json from conf.d/ cops\_slack handler would kick in as expected and would report to the expected channel but as soon as I bring back my\_handler (restart sensu server, api) the same check now would report to the channel mentioned in my\_handler. I have reproduced this several times and am out of ideas here. I would be grateful if some one can help me out here.
> 
> > > > >
> 
> > > > > Thanks
> 
> > > >

---

<div class="post-metadata">

**Author:** ![David\_R](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@David\_R](https://discourse.sensu.io/u/David_R)\
**Post date:** [April 26, 2017, 1:10pm UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/7 "2017-04-26T13:10:06Z")

</div>

Aiman,

I was still running into an issue as we have a proxy, but your example really helped me to find the solution, and I wanted to share it here.

For those using a proxy and wanting to use handler-slack-multichannel.rb, know that the setting/option for proxy\_address is NOT the same in handler-slack-multichannel.rb as in handler-slack.rb.

The handler-slack.rb file uses/expects proxy\_address to be passed as setting/parameter in ones slack handler configuration. Whereas handler-slack-multichannel.rb expects proxy\_addr in the handler configuration - this is the key difference. Before I found this, none of my alerts were going to slack at all.

I never would have went into the source had you not posted your config. When I saw your config I said “Huh, where in handler-slack.rb can we define markdown mode? I don’t see it on their main documentation page, let me look at the source.” When it wasn’t in the source code for handler-slack.rb, I went to look at handler-slack-multichannel.rb and saw it declared there. For giggles I thought “I wonder if all of the proxy get\_settings options are the same here?” and they weren’t.

So, hopefully this helps someone who’s using a proxy and still wants slack multichannel goodness.

Thanks, again, Aiman!

David

> **···**
>
> On Tuesday, April 25, 2017 at 2:16:46 PM UTC-4, David R wrote:
> 
> > Hey, Aiman,
> 
> > This is immensely helpful; thank you!
> 
> > 
> 
> > David
> > 
> > On Tuesday, April 25, 2017 at 1:24:10 PM UTC-4, aiman parvaiz wrote:
> > 
> > > Hey David  
> > > The way I got it working is as follows:
> 
> > > I am using multichannel\_slack.rb and I have it’s json file in the conf.d directory, this is the content of that file:
> 
> > >
> 
> > >
> 
> > > {
> 
> > > “handlers”: {
> 
> > > “multi\_slack”: {
> 
> > > “channels”: {
> 
> > > “default”: [“#alerts”]
> 
> > > },
> 
> > > “type”: “pipe”,
> 
> > > “command”: “/etc/sensu/handlers/multichannel\_slack.rb”
> 
> > > }
> 
> > > },
> 
> > > “slack”: {
> 
> > > “webhook\_url”:“[https://hooks.slack.com/asdervsdft](https://hooks.slack.com/asdervsdft)”,
> 
> > > “channel”: “#alerts”,
> 
> > > “bot\_name”: “Sensu”,
> 
> > > “markdown\_enabled”: true
> 
> > > }
> 
> > > }
> 
> > > All alerts by default go to #alerts, in cases where I want to report to some other channel I include the channel name in the json of the check, for example:
> 
> > >
> 
> > > {
> 
> > > “checks”: {
> 
> > > “cassandra\_check”: {
> 
> > > “command”: “check-process.rb -p cassandra -C 1 -x ‘.log$’”,
> 
> > > “handler”:“multi\_slack”,
> 
> > > “subscribers”: [
> 
> > > “cassandra”,
> 
> > > ],
> 
> > > “slack”: {
> 
> > > “channels”:[“#cops-alerts”]
> 
> > > },
> 
> > > “interval”: 60
> 
> > > }
> 
> > > }
> 
> > > }
> 
> > > and this way I am able to get alerts sent to various channels, my requirement was to send the alert to any one of the channels depending on the check and this solution works for that case.
> 
> > > I hope this helps.
> 
> > > Thanks
> 
> > >
> 
> > > On Thursday, April 20, 2017 at 5:21:21 AM UTC-7, David R wrote:
> > > 
> > > > The documentation embedded into the source for the handler-slack-multichannel is a bit sparse. Any ideas on how one would define the various channels? For the basic slack module, one has to define a webhook\_url. Presumably, with the multichannel plugin, one would have a list of webhook\_urls to define for the various channels (default, compulsory, etc). I’ve tried a few variations on my own, but to no avail. Any guidance would be most appreciated!
> > > > 
> > > > On Wednesday, February 22, 2017 at 11:48:08 PM UTC-5, Kyle Anderson wrote:
> > > > 
> > > > > All the json files in conf.d get merged together, so there is only one “slack”: configuration hash manifesting.
> 
> > > > > You will probably have to do something that understands multi-channel more natively
> 
> > > > > [https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb](https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack-multichannel.rb)
> 
> > > > >
> 
> > > > >
> 
> > > > > On Wed, Feb 22, 2017 at 7:09 PM, aiman parvaiz [aimanp...@gmail.com](mailto:aimanp...@gmail.com) wrote:
> > > > > 
> > > > > > Hi all  
> > > > > > I am trying to get certain alerts to one slack channel and rest to a separate one. I am using sensu 0.26.5. I have two json files for handlers in /etc/sensu/conf.d
> 
> > > > > >
> 
> > > > > > 1. cops\_slack.json
> 
> > > > > >
> 
> > > > > > {
> 
> > > > > > “handlers”: {
> 
> > > > > > “cops\_slack”: {
> 
> > > > > > “type”: “pipe”,
> 
> > > > > > “command”: “/etc/sensu/handlers/cops\_slack.rb”
> 
> > > > > > }
> 
> > > > > > },
> 
> > > > > > “slack”: {
> 
> > > > > > “webhook\_url”:"[https://hooks.slack.com/services/XXXDDDD](https://hooks.slack.com/services/XXXDDDD),
> 
> > > > > > “channel”: “#alerts1”,
> 
> > > > > > “bot\_name”: “Sensu”,
> 
> > > > > > “markdown\_enabled”: true
> 
> > > > > > }
> 
> > > > > > }
> 
> > > > > >
> 
> > > > > >
> 
> > > > > > 1. my\_handler.json
> 
> > > > > >
> 
> > > > > > {
> 
> > > > > > “handlers”: {
> 
> > > > > > “slack”: {
> 
> > > > > > “type”: “pipe”,
> 
> > > > > > “command”: “/etc/sensu/handlers/my\_handler\_slack.rb”
> 
> > > > > > }
> 
> > > > > > },
> 
> > > > > > “slack”: {
> 
> > > > > > “webhook\_url”: “[https://hooks.slack.com/services/XXX](https://hooks.slack.com/services/XXX)”,
> 
> > > > > > “channel”: “#backend-core-alerts”,
> 
> > > > > > “bot\_name”: “Sensu”,
> 
> > > > > > “markdown\_enabled”: true
> 
> > > > > > }
> 
> > > > > > }
> 
> > > > > >
> 
> > > > > > I am specifying handler to use in the check definition, for example:
> 
> > > > > >
> 
> > > > > > {
> 
> > > > > > “checks”: {
> 
> > > > > > “cassandra\_ntp”: {
> 
> > > > > > “handler”: “cops\_slack”,
> 
> > > > > > “command”: “check-process.rb -p ntp -W 1”,
> 
> > > > > > “subscribers”: [
> 
> > > > > > “ABCD”
> 
> > > > > > ],
> 
> > > > > > “interval”: 60
> 
> > > > > > }
> 
> > > > > > }
> 
> > > > > > }
> 
> > > > > >
> 
> > > > > > This setup is not working for me. For some strange reasons if I remove my\_handler.json from conf.d/ cops\_slack handler would kick in as expected and would report to the expected channel but as soon as I bring back my\_handler (restart sensu server, api) the same check now would report to the channel mentioned in my\_handler. I have reproduced this several times and am out of ideas here. I would be grateful if some one can help me out here.
> 
> > > > > >
> 
> > > > > > Thanks
> 
> > > > >

---

<div class="post-metadata">

**Author:** ![aiman\_parvaiz1](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@aiman\_parvaiz1](https://discourse.sensu.io/u/aiman_parvaiz1)\
**Post date:** [April 28, 2017, 2:02pm UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/8 "2017-04-28T14:02:58Z")

</div>

Glad to be of help!!

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [November 22, 2018, 2:07am UTC](https://discourse.sensu.io/t/struggling-to-get-slack-report-to-two-different-channels/771/9 "2018-11-22T02:07:48Z")

</div>


