Sensu Plugins Mailer not honoring subscriptions based mail_to list

#1

Check.json:

{
“checks”: {
“Nginx”: {
“command”: “/opt/sensu/embedded/bin/check-process.rb -p nginx”,
“handler”: “mailer”,
“interval”:5,
“subscribers”:[“monitoring-sensu-prod”,“monitoring-sensupoc-sim”],
“type”:“standard”,
“low_flap_threshold”: 20,
“high_flap_threshold”: 60,
“occurrences”: 3
}
}
}

Client.json:

  1. Client1 subscriptions

{
“client”: {
“subscriptions”: [“Linux”, “standard”, “monitoring-sensupoc-sim”, “monitoring”]
}
}

  1. Client2 subscriptions

{
“client”: {
“subscriptions”: [“Linux”, “standard”, “monitoring-sensu-prod”, “monitoring”]
}
}

Mailer.json
{
“mailerjson”:
{
“mail_from”: “sensu@syz .com”,
“smtp_address”: “xxx”,
“smtp_use_tls”: false,
“smtp_port”: 25,
“admin_gui”: “uchiwaxyz .com/”,
“subscriptions”:
{
“monitoring-sensupoc-sim”: {“mail_to”: “name1@ xyz .com” },
“monitoring-sensu-prod”: {“mail_to”: “name2@ xyz .com” }
}
},
“handlers”: {
“mailer”: {
“type”: “pipe”,
“command”: “/opt/sensu/embedded/bin/handler-mailer.rb -j mailerjson”
}
}
}

Observation:
When nginx is stopped on client1 [subscription monitoring-sensupoc-sim] => I get emails sent to both name1@xyz. com and name2@xyz. com

Exact log:
{“timestamp”:“2019-05-13T22:21:44.228660+0000”,“level”:“info”,“message”:“handler output”,“handler”:{“type”:“pipe”,“command”:"/opt/sensu/embedded/bin/handler-mailer.rb -j mailerjson",“handle_flapping”:true,“severities”:[“warning”,“critical”],“filters”:[“occurrences”],“name”:“mailer”},“event”:{“id”:“d1708157-a14d-4b28-93ef-4a4cce5bb399”},“output”:[“mail – sent alert for client1/Nginx to , name1@xyz. com,name2@xyz. com\n”]}

Expectation:
All alerts from monitoring-sensupoc-sim should go only to name1@xyz. com. As stated on github.com sensu-plugins/sensu-plugins-mailer

There is an optional subscriptions hash which can be added to your mailer.json file. This subscriptions hash allows you to define individual mail_to addresses for a given subscription. When the mailer handler runs it will check the clients subscriptions and build a mail_to string with the default mailer.mail_to address as well as any subscriptions the client subscribes to where a mail_to address is found. There can be N number of hashes inside of subscriptions but the key for a given hash inside of subscriptions must match a subscription name.

Send notifications based on subscriptions