sensu-plugins-opsgenie 4.2.0 → 4.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60da9a2150addc0545bb2b0f982c4f803e6fc8444b26499a9ff55a3dc10571a2
4
- data.tar.gz: 4af0d744eb11c9e6633c01f2be7f85a7ecccb89b7795f17bdbed220da73a7095
3
+ metadata.gz: ce34ed8a0583ac583dd50ec3aa3ae967be8f5d522106b6c1c21a6d8d2e25c33a
4
+ data.tar.gz: 0f820e7f989f0ab24e4fc56c7dce67e57885ecacd246a63e9b165d0fcb88781a
5
5
  SHA512:
6
- metadata.gz: 517c8af283e218ef9bef4bda6034c70866d38509ac5eb996f56f6f817b8001e2c1d849fab103fb53cf3c4e07f93e60d49cab3d08524710aefb1a62b8a41c414d
7
- data.tar.gz: 27e42a03d769276d52f77ae245bcfce0da47cf74ee2ecc259d860e182623f9b95509f092a13c1c99cebf82b786232d376a5f4fcc761bd4d2e63c5a4760cb0a55
6
+ metadata.gz: a91fade8878d7d4d534da490ae4b87feaca94f14b9d7a5a5284c711677ed0d790425fb9dab5fb0285936a3ca93fa82d0dee6cf7918a547f187dc42be9f97b49b
7
+ data.tar.gz: 43b64e314638939b3855493a9e12e8661cc50364a251de0708f2ec93a0599fc5d03391ccb21160d4b20f940224c62f20139b283f3822733b70b00fdead829988
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.3.0] - 2018-03-21
9
+ ### Added
10
+ - Added possibility to specify priority per check (@Castaglia)
11
+
8
12
  ## [4.2.0] - 2018-02-20
9
13
  ### Changed
10
14
  - Providing better alert description field using Sensu check output (@Castaglia)
@@ -106,7 +110,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
106
110
  - initial release
107
111
  - Fixed json configuration load
108
112
 
109
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.2...HEAD
113
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.3.0...HEAD
114
+ [4.3.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.2.0...4.3.0
110
115
  [4.2.0]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.2...4.2.0
111
116
  [4.1.2]: https://github.com/sensu-plugins/sensu-plugins-opsgenie/compare/4.1.1...4.1.2
112
117
  [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.
@@ -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',
@@ -129,6 +131,19 @@ class Opsgenie < Sensu::Handler
129
131
  teams: json_config['teams'])
130
132
  end
131
133
 
134
+ def event_priority
135
+ return DEFAULT_PRIORITY unless json_config['priority']
136
+ priority = json_config['priority']
137
+
138
+ canonical_priority = priority.upcase
139
+ unless PRIORITIES.include? canonical_priority
140
+ puts "opsgenie -- ignoring unsupported priority '#{priority}'"
141
+ canonical_priority = DEFAULT_PRIORITY
142
+ end
143
+
144
+ canonical_priority
145
+ end
146
+
132
147
  def tags
133
148
  tags = []
134
149
  tags += json_config['tags'] if json_config['tags']
@@ -141,9 +156,13 @@ class Opsgenie < Sensu::Handler
141
156
  end
142
157
 
143
158
  def post_to_opsgenie(action = :create, params = {})
144
- # override source if specified, default is ip
159
+ # Override source if specified, default is ip
145
160
  params['source'] = json_config['source'] if json_config['source']
146
161
 
162
+ # Override priority, if specified.
163
+ priority = event_priority
164
+ params['priority'] = priority if priority
165
+
147
166
  encoded_alias = URI.escape(params[:alias])
148
167
  # TODO: come back and asses if this logic is correct, I left it functionally
149
168
  # as it was originally written but I suspect we should have at least three
@@ -5,7 +5,7 @@ module SensuPluginsOpsgenie
5
5
  # This defines the version of the gem
6
6
  module Version
7
7
  MAJOR = 4
8
- MINOR = 2
8
+ MINOR = 3
9
9
  PATCH = 0
10
10
 
11
11
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
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.2.0
4
+ version: 4.3.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: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin