Custom Sensu Handlers to support a multi-tenant environment, allowing checks themselves to emit the type of handler behavior they need in the event json
I tested this by going on an admin host, editing /etc/sensu/conf.d/handlers/jira.json and adding this snippet at the end as a sample priority map (this will come from puppet hieradata instead, but this was just for testing):
"priority_map": {
"0": "0 Drop everything",
"1": "1 Do now",
"2": "2 Do next"
}
I then took the snippet that @giuliano108 used for testing in #129 and modified it to have a priority parameter in the check set to 0 and it created PINCUSHION-1977 with the correct priority. Same with PINCUSHION-1978 when I set it to 2 (although that's also the default). With a priority not in the map, I tested and it just uses P2 as a fallback, and I also tested with something like "0": "3 Nice to have" (mostly for fun) and that also worked fine and created a P3 ticket when passed 0 as a check priority.
This whole mapping this is here because you can only set the priority of tickets by using the priority's name, or its ID. The IDs we have are something like 6 for a P0, 7 for a P1, etc. (not sure why it's offset), so I thought the names would make more sense, but didn't want to have to write out the whole priority name for each alert or wherever needed, so the map is there to convert from a short priority value to the full name (and make it easier to fix if the priorities change names in the future).
I also removed an old lucid patch for jira that we shouldn't need any more.
I tested this by going on an admin host, editing
/etc/sensu/conf.d/handlers/jira.json
and adding this snippet at the end as a sample priority map (this will come from puppet hieradata instead, but this was just for testing):I then took the snippet that @giuliano108 used for testing in #129 and modified it to have a
priority
parameter in the check set to0
and it created PINCUSHION-1977 with the correct priority. Same with PINCUSHION-1978 when I set it to2
(although that's also the default). With a priority not in the map, I tested and it just uses P2 as a fallback, and I also tested with something like"0": "3 Nice to have"
(mostly for fun) and that also worked fine and created a P3 ticket when passed0
as a check priority.This whole mapping this is here because you can only set the priority of tickets by using the priority's name, or its ID. The IDs we have are something like 6 for a P0, 7 for a P1, etc. (not sure why it's offset), so I thought the names would make more sense, but didn't want to have to write out the whole priority name for each alert or wherever needed, so the map is there to convert from a short priority value to the full name (and make it easier to fix if the priorities change names in the future).
I also removed an old lucid patch for jira that we shouldn't need any more.