sensu-plugins/sensu-plugins-mailer

It would be great to pass a To: argument in the handler rather than specifying it in the config

AirCombat opened this issue · 6 comments

It would be great to pass a To: argument in the handler or define To in the handler config rather than specifying it in the plugins json config.

That way I could email different distribution groups / addresses for different checks.

Hi there,
I'm also trying to send alerts to different groups for different checks. This is a great and very useful feature, please look into adding it.
Essentially, the contact routing feature from Sensu Enterprise is what I'm looking for: https://sensuapp.org/docs/0.24/enterprise/contact-routing.html

I've created a pull request to be able to add contacts for particular checks, which is especially useful for standalone checks which don't have a subscription to send e-mails to. This mimics the Sensu Enterprise contact routing configuration, while keeping the existing functionality in the handler as well.

Hopefully we can get this into the mailer handler since it's something we're all looking for.

@stevenviola that has been merged and released but it looks like it's ported as being buggy in #55 any chance you can take a look since you are probably more familiar with this code than I am. When I have some more time I will try to triage it as well.

Hi Team, just trying to get an understanding a bit more on this plugin. Is it possible to pass a To: argument / email in the check result rather than specifying it in the server side config? All of these configurations seem to suggest that they need to pre-defined in the mailer config or contact routing.

@codepattern the contact routing in this plugin works the same way as contact routing does in the Enterprise version, and requires the e-mail addresses to be listed in the config on the sensu-server.

Quickly looking over the plugin, if you don't want to specify the e-mail address on the sensu-server at all, I think your only option is to add a mail_to parameter to your client config, and specify the e-mail address there. This would then apply to all checks on that client. There doesn't look like a way to have a mail_to on a per check basis.

We could add support to have mail_to come from check -> client -> server in that order and is a pretty common pattern that handlers follow. I'd be 👍 to reviewing a PR that does that.