Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]
- Added possibility to specify different priorities per status (@passing)

## [5.0.0] - 2019-03-05
### Breaking Changes
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,17 @@ The list of valid values, per [OpsGenie alert docs](https://docs.opsgenie.com/do
* P5

Any value other than these will be ignored.

You can as well configure different priorities per status:
```
{
"checks": {
"check_mysql_access": {
"opsgenie": {
"priority": {
"critical": "P1",
"warning": "P2",
"unknown": "P5"
}

```
13 changes: 11 additions & 2 deletions bin/handler-opsgenie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,17 @@ def create_alert
end

def event_priority
return DEFAULT_PRIORITY unless json_config['priority']
priority = json_config['priority']
if event_status == 1 && json_config['priority']['warning']
priority = json_config['priority']['warning']
elsif event_status == 2 && json_config['priority']['critical']
priority = json_config['priority']['critical']
elsif event_status >= 3 && json_config['priority']['unknown']
priority = json_config['priority']['unknown']
elsif json_config['priority']
priority = json_config['priority']
else
return DEFAULT_PRIORITY
end

canonical_priority = priority.upcase
unless PRIORITIES.include? canonical_priority
Expand Down