So, we're transitioning from Slack to MSTeams. I'm tasked with updating our Sensu configuration so that alerts get sent to MSTeams channels instead of Slack channels.
In the /etc/sensu/conf.d/handlers.json
, we have Slack notifications configured as follows:
...
"slack" : {
"type": "pipe",
"command": "handler-slack.rb -j slack",
"filters": [
"occurrences"
]
},
....
That -j slack
tells the handler to load a JSON config file which is located at /etc/sensu/conf.d/slack.d/slack.json
.
The Teams handler is configured similarly:
...
"microsoft-teams" : {
"type": "pipe",
"command": "handler-microsoft-teams.rb -j microsoft-teams",
"filters": [
"occurrences"
]
},
...
But when Sensu tries to pass a notification to the Teams handler, I get an error that leads me to believe that the JSON config wasn't loaded:
/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-microsoft-teams-2.0.0/bin/handler-microsoft-teams.rb:104:in `get_setting': undefined method `[]' for nil:NilClass (NoMethodError)
from /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-microsoft-teams-2.0.0/bin/handler-microsoft-teams.rb:28:in `payload_template'
from /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugins-microsoft-teams-2.0.0/bin/handler-microsoft-teams.rb:108:in `handle'
from /opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/sensu-plugin-2.7.1/lib/sensu-handler.rb:89:in `block in <class:Handler>'
payload_template
is the first setting that handler-microsoft-teams.rb attempts to load. It is not specified in my JSON, and the code is written to treat it as optional.
So, my question is this: how does the Slack plugin go from the string passed to the -j
argument (slack
) to the path /etc/sensu/conf.d/slack.d/slack.json
? And how do I determine the equivalent path magic for the Teams plugin? I don't know if this magic is inherent in Ruby (in which I'm a non-expert), Sensu, sensu-plugins, or something else. I've been digging in code for a while now and I'm coming up empty.
(Yes, I'm aware of Sensu Go and would like to upgrade; that's not an option on my current timeline.)