sensu-plugins-opsgenie 4.2.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -1
- data/README.md +26 -0
- data/bin/handler-opsgenie.rb +29 -2
- data/lib/sensu-plugins-opsgenie/version.rb +2 -2
- metadata +12 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0608935d141e4ae3e702f438327df42b6c9b932596cbee8a502314f9c2ce899
|
4
|
+
data.tar.gz: 1dbb40c4e8295e52b7c475f0e404e62660559276a522a47386f4199237596925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff77b0452136239a1cc601b9bffbff1b985e8dc966fac57c53a8fd7e90ad4fdde685f54d2a117343f5749eb10cc831fd6ab0efa4deefe3ef2cf6f537f7014475
|
7
|
+
data.tar.gz: 875ef0d4eeff85043caf8c0221340a2003f8fabc13df73e8a5d691b8bea28d1e8d582c6c33914345f5eb4adbf1bfd9e1741ac6a8ee65733b760fa016a9cb7796
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,21 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [5.1.0] - 2022-03-28
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- adding `details` to handler if present (@saurabh-iitrke)
|
12
|
+
|
13
|
+
## [5.0.0] - 2019-03-05
|
14
|
+
### Breaking Changes
|
15
|
+
- Bump sensu-plugin version from `~> 2.0` to `~> 4.0` for Sensu 1.x to Sensu Go event conversion you can read the changelog entries for [4.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#400---2018-02-17) and [3.0](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#300---2018-12-04)
|
16
|
+
- drop support and testing for ruby 2.1 and 2.2 as they are EOL
|
17
|
+
=======
|
18
|
+
|
19
|
+
## [4.3.0] - 2018-03-21
|
20
|
+
### Added
|
21
|
+
- Added possibility to specify priority per check (@Castaglia)
|
22
|
+
|
8
23
|
## [4.2.0] - 2018-02-20
|
9
24
|
### Changed
|
10
25
|
- Providing better alert description field using Sensu check output (@Castaglia)
|
@@ -106,7 +121,10 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
106
121
|
- initial release
|
107
122
|
- Fixed json configuration load
|
108
123
|
|
109
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/
|
124
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/5.1.0...HEAD
|
125
|
+
[5.1.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/5.0.0...5.1.0
|
126
|
+
[5.0.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.3.0...5.0.0
|
127
|
+
[4.3.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.2.0...4.3.0
|
110
128
|
[4.2.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.2...4.2.0
|
111
129
|
[4.1.2]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.1...4.1.2
|
112
130
|
[4.1.1]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.0...4.1.1
|
data/README.md
CHANGED
@@ -130,6 +130,10 @@ assign the default priority of "P3" to the alert.
|
|
130
130
|
|
131
131
|
## Configuration Notes
|
132
132
|
|
133
|
+
### Per Check Attributes
|
134
|
+
|
135
|
+
#### `alias`
|
136
|
+
|
133
137
|
If the check definition uses the custom `alias` attribute, _e.g._:
|
134
138
|
```
|
135
139
|
{
|
@@ -182,3 +186,25 @@ We can define a custom `alias` attribute in this check:
|
|
182
186
|
And with this, running on multiple clients, any alerts would be generated
|
183
187
|
with the same event ID of `mysqldb`, by using that `alias` attribute as the
|
184
188
|
event ID.
|
189
|
+
|
190
|
+
#### `priority`
|
191
|
+
|
192
|
+
By default, an OpsGenie alert is created with a default [priority](https://docs.opsgenie.com/docs/priority-settings) value of "P3". The priority for a specific
|
193
|
+
check can be explicitly set using the custom `priority` attribute, _e.g._:
|
194
|
+
```
|
195
|
+
{
|
196
|
+
"checks": {
|
197
|
+
"check_mysql_access": {
|
198
|
+
"opsgenie": {
|
199
|
+
"priority": "P1",
|
200
|
+
|
201
|
+
```
|
202
|
+
The list of valid values, per [OpsGenie alert docs](https://docs.opsgenie.com/docs/alert-api#section-create-alert), are:
|
203
|
+
|
204
|
+
* P1
|
205
|
+
* P2
|
206
|
+
* P3
|
207
|
+
* P4
|
208
|
+
* P5
|
209
|
+
|
210
|
+
Any value other than these will be ignored.
|
data/bin/handler-opsgenie.rb
CHANGED
@@ -14,6 +14,8 @@ class Opsgenie < Sensu::Handler
|
|
14
14
|
attr_reader :json_config, :message_template, :verbose
|
15
15
|
|
16
16
|
OPSGENIE_URL = 'https://api.opsgenie.com/v2/alerts'.freeze
|
17
|
+
PRIORITIES = %w[P1 P2 P3 P4 P5].freeze
|
18
|
+
DEFAULT_PRIORITY = 'P3'.freeze
|
17
19
|
|
18
20
|
option :json_config,
|
19
21
|
description: 'Configuration name',
|
@@ -118,6 +120,12 @@ class Opsgenie < Sensu::Handler
|
|
118
120
|
@event['client']['name']
|
119
121
|
end
|
120
122
|
|
123
|
+
def details
|
124
|
+
details = {}
|
125
|
+
return @event['check']['opsgenie']['details'] unless @event['check']['opsgenie'].nil? || @event['check']['opsgenie']['details'].nil?
|
126
|
+
details
|
127
|
+
end
|
128
|
+
|
121
129
|
def create_alert
|
122
130
|
post_to_opsgenie(:create,
|
123
131
|
alias: event_id,
|
@@ -126,7 +134,21 @@ class Opsgenie < Sensu::Handler
|
|
126
134
|
entity: client_name,
|
127
135
|
tags: tags,
|
128
136
|
recipients: json_config['recipients'],
|
129
|
-
teams: json_config['teams']
|
137
|
+
teams: json_config['teams'],
|
138
|
+
details: details)
|
139
|
+
end
|
140
|
+
|
141
|
+
def event_priority
|
142
|
+
return DEFAULT_PRIORITY unless json_config['priority']
|
143
|
+
priority = json_config['priority']
|
144
|
+
|
145
|
+
canonical_priority = priority.upcase
|
146
|
+
unless PRIORITIES.include? canonical_priority
|
147
|
+
puts "opsgenie -- ignoring unsupported priority '#{priority}'"
|
148
|
+
canonical_priority = DEFAULT_PRIORITY
|
149
|
+
end
|
150
|
+
|
151
|
+
canonical_priority
|
130
152
|
end
|
131
153
|
|
132
154
|
def tags
|
@@ -141,9 +163,13 @@ class Opsgenie < Sensu::Handler
|
|
141
163
|
end
|
142
164
|
|
143
165
|
def post_to_opsgenie(action = :create, params = {})
|
144
|
-
#
|
166
|
+
# Override source if specified, default is ip
|
145
167
|
params['source'] = json_config['source'] if json_config['source']
|
146
168
|
|
169
|
+
# Override priority, if specified.
|
170
|
+
priority = event_priority
|
171
|
+
params['priority'] = priority if priority
|
172
|
+
|
147
173
|
encoded_alias = URI.escape(params[:alias])
|
148
174
|
# TODO: come back and asses if this logic is correct, I left it functionally
|
149
175
|
# as it was originally written but I suspect we should have at least three
|
@@ -167,6 +193,7 @@ class Opsgenie < Sensu::Handler
|
|
167
193
|
puts "Teams: #{params[:teams]}"
|
168
194
|
puts "Alias: #{params[:alias]}"
|
169
195
|
puts "Description: #{params[:description]}"
|
196
|
+
puts "Details: #{params[:details]}"
|
170
197
|
end
|
171
198
|
|
172
199
|
http = Net::HTTP.new(uri.host, uri.port)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-opsgenie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
47
|
+
version: '1.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: github-markup
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,14 +134,14 @@ dependencies:
|
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
137
|
+
version: '13.0'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: '
|
144
|
+
version: '13.0'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: redcarpet
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,14 +190,14 @@ dependencies:
|
|
190
190
|
requirements:
|
191
191
|
- - "~>"
|
192
192
|
- !ruby/object:Gem::Version
|
193
|
-
version: 2.
|
193
|
+
version: 2.41.5
|
194
194
|
type: :development
|
195
195
|
prerelease: false
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
197
197
|
requirements:
|
198
198
|
- - "~>"
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: 2.
|
200
|
+
version: 2.41.5
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: test-kitchen
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,15 +259,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
259
259
|
requirements:
|
260
260
|
- - ">="
|
261
261
|
- !ruby/object:Gem::Version
|
262
|
-
version: 2.
|
262
|
+
version: 2.3.0
|
263
263
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
264
264
|
requirements:
|
265
265
|
- - ">="
|
266
266
|
- !ruby/object:Gem::Version
|
267
267
|
version: '0'
|
268
268
|
requirements: []
|
269
|
-
|
270
|
-
rubygems_version: 2.7.6
|
269
|
+
rubygems_version: 3.1.2
|
271
270
|
signing_key:
|
272
271
|
specification_version: 4
|
273
272
|
summary: Sensu plugins for working with opsgenie
|