Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only configured channels recieve notifications? #53

Open
maaark11 opened this issue Oct 11, 2017 · 9 comments
Open

Only configured channels recieve notifications? #53

maaark11 opened this issue Oct 11, 2017 · 9 comments

Comments

@maaark11
Copy link

maaark11 commented Oct 11, 2017

I has configured one channel in slack.json but i want to send to N others with override using in check but my checks only send if channel are configured in slack.json like:

...
"webhook_urls": {
			"zz": "https://hooks.slack.com/services/BLA/bla123"
		},
...

On this way only work to checks notify zz channel other checks doesn't work.

This webhook should working to all channels and can override with check channel, right?

EDIT:
I currently use this way, this webhook and with this configuration and the check overwrite the "default" channel but in previous version of

E.G.

on cliente the check is

{
  "checks": {
    "sensu_api_process_check": {
      "command": "check-process.rb -p 'sleep'",
      "standalone": true,
      "handlers": ["slack", "graphite", "default"],
      "interval": 10,
      "ttl": 300,
      "aggregate": "dev",
      "slack": {
         "channels": [ "#eng" ]
      }
    }
  }
}
@maaark11 maaark11 changed the title Only configured channels recieve notificatons? Only configured channels recieve notifications? Oct 11, 2017
@autumnw
Copy link
Contributor

autumnw commented Oct 19, 2017

In slack, if I want one app(suppose it is your sensu server) send message to multiple channels, I need to generate one webhook URL for each channel. Then I need to configure all those webhooks into "webhook_urls".
I may define default channels in configuration. And it will be overriden in client or check configurations. Here is an example of slack_handler.json for multiple channel handler:

{
    "handlers": {
        "slack": {
            "type": "pipe",
            "command": "/opt/sensu/embedded/bin/handler-slack-multichannel.rb",
            "filters": ["check_dependencies"],
            "services": ["critical", "unknown"]
        }
    },
    "slack": {
        "template" : "",
        "webhook_urls": {
            "channel1": "https://hooks.slack.com/services/aaaaaaaaaa/aaaa/aaaaaaa",
            "channel2": "https://hooks.slack.com/services/aaaaaaaaa/bbbb/cccccc",
            "channel3": "https://hooks.slack.com/services/aaaaaaaaa/bbbb/ddddddd"
        },
        "channels": {
            "default": ["channel1"]
        }
    }
}

@majormoses
Copy link
Member

@maaark11 does that answer your question?

@maaark11
Copy link
Author

maaark11 commented Nov 1, 2017

Let me explain my use case:

Using the 1.0.0 version of the plugin I was able to override the channel when configuring the client JSON (within a standalone check). This way, I only needed to define one hook and one default channel on the server side. If I don’t define a channel in the standalone client check, the handler would use the default one.

In my experiments with the latest version, I couldn’t replicate this behavior. Was this feature removed from the plugin?

@autumnw
Copy link
Contributor

autumnw commented Nov 2, 2017 via email

@majormoses
Copy link
Member

Most suspicious line in diff between the two versions: 1.0.0...2.0.0#diff-2e9b02e7ca696b0f2435aa02a93649ebR103

@maaark11
Copy link
Author

maaark11 commented Nov 7, 2017

@majormoses the link is broken

@majormoses
Copy link
Member

grr github changed some stuff one sec I will get a working one...

@majormoses
Copy link
Member

actually looking back that change was only for handler-slack.rb and you are using the multi channel one.

@majormoses
Copy link
Member

majormoses commented Jan 12, 2018

Sorry for the delayed response I have not had the time to circle back until now. So let me make sure I understand what you want vs what happens:

What you would like to happen

Define a default channel for the handler on the server side, another inside a check (example is standalone but realistically it applies to a subscription check as well). This should result in an alert going to both channels.

What actually happens

Define a default channel for the handler on the server side and a different in a check. This should result in sending to only the one defined in the check.

Thoughts

Assuming what I have above is correct I think I see where this behavior changed. This was intentional and I believe I missed your intended use case while reviewing. The change happened here: #45. I am conflicted on what we should do here. On the one hand I do think that in some scenarios it might be desirable to say this default channel must fire every time while you can additionally add channels. On the other hand I think that a default is just that a default meant to be overwritten. This follows the same pattern as sensu redaction as well as the pagerduty handler for teams/services. We could add new configuration options to allow finer control of the behavior. For example instead of having just channels we could have:

  • default_channels: I don't think this is required and I think this can just be a fallback for channels, that being said this prevents a breaking change (although technically it would be on a regression)
  • required_channels: This would always ensure that these channels are sent to as well as (channel|default_channel)
  • channels: could either be defined in check or pulls default from handler config otherwise, like the default above it technically would break backwards compatibility on a regression.

These are just a few thoughts, open to suggestions. @eheydrick thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants