kennel 2.11.0 → 2.12.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: 88495b67d113181455cb6dc751d2f7820eababca5679cfb714bb614dc9370ad6
4
- data.tar.gz: a8703613913aa4557c585e605f35a1aef9555902c65a5f1c1772b1038e9d4d34
3
+ metadata.gz: ef24e36c2feeba08b92edd003e6d11bfefaa31bd0839765393325b29e8132cb3
4
+ data.tar.gz: 54f97c79250c564d62f01837cc85badc4cdc3357860f40e0408d33640d1a94a8
5
5
  SHA512:
6
- metadata.gz: d730ee50ff704f25eb39fdd8daa9c95a2c0b43f9a9534c7f1a05a245bd3881ab5ce36f12ebf226354eeafe94c4a961e843eebbbcf0312b2b548577b26a4debdd
7
- data.tar.gz: ff487e51479e7a463464e37ec09a10ef7c1dc7d695bcf18f97303048ab0a75759d71eda14aa95e512aa69b66c25baf016d778be449455c0ef069e081f5957373
6
+ metadata.gz: '08b01acd5c750342d5134e6c2ca6d235bdb5cefc8f0b61b46e7b475ed7be6fd677772bab5a032d2a67685e02389d6741f05ef1e05a0758d3c6f6ff2fae68cb0d'
7
+ data.tar.gz: 79cc9956a1b1790c2e6bfb7f25c981542a2b21d96f8c3d1bdc5328d1e708c410372fa9405bf16a3fbaf7a27aaf1954ca71cb760ae4bfad82fa346b10635b0e8c
@@ -56,6 +56,7 @@ module Kennel
56
56
  # datadog UI sets this to false by default, but true is safer
57
57
  # except for log alerts which will always have "no error" gaps and should default to false
58
58
  notify_no_data: -> { !SKIP_NOTIFY_NO_DATA_TYPES.include?(type) },
59
+ no_data_timeframe: -> { MONITOR_OPTION_DEFAULTS.fetch(:no_data_timeframe) },
59
60
  notify_audit: -> { MONITOR_OPTION_DEFAULTS.fetch(:notify_audit) },
60
61
  new_host_delay: -> { MONITOR_OPTION_DEFAULTS.fetch(:new_host_delay) },
61
62
  new_group_delay: -> { nil },
@@ -149,16 +150,25 @@ module Kennel
149
150
  # and enforce that it is not set at the same time as on_missing_data
150
151
  def configure_no_data
151
152
  notify = notify_no_data
153
+ timeframe = no_data_timeframe
152
154
  action = on_missing_data
155
+ action ||= "default" if type == "event-v2 alert"
153
156
 
154
- # on_missing_data cannot be used with notify_no_data or no_data_timeframe
155
- if type == "event-v2 alert" || action
156
- # TODO: mark setting notify_no_data or no_data_timeframe at all as invalid
157
+ # TODO: mark setting action && !notify.nil? at all as invalid
158
+ if action && timeframe
159
+ invalid! :invalid_no_data_config, "set either no_data_timeframe or on_missing_data"
160
+ end
161
+ if type == "composite" && action
162
+ invalid! :invalid_no_data_config, "cannot use on_missing_data with composite monitor"
163
+ end
164
+
165
+ # on_missing_data cannot be used with notify_no_data + no_data_timeframe
166
+ if action
157
167
  { on_missing_data: action || "default" }
158
168
  else
159
169
  {
160
170
  notify_no_data: notify,
161
- no_data_timeframe: notify ? no_data_timeframe : nil
171
+ no_data_timeframe: notify ? no_data_timeframe || default_no_data_timeframe : nil
162
172
  }
163
173
  end
164
174
  end
@@ -184,7 +194,7 @@ module Kennel
184
194
  # deprecated this setting is no longer returned by dd for new monitors
185
195
  # datadog UI warns when setting no data timeframe to less than 2x the query window
186
196
  # limited to 24h because `no_data_timeframe must not exceed group retention` and max group retention is 24h
187
- def no_data_timeframe
197
+ def default_no_data_timeframe
188
198
  default = 60
189
199
  if type == "query alert" && (minutes = query_window_minutes)
190
200
  (minutes * 2).clamp(default, 24 * 60)
@@ -305,9 +315,11 @@ module Kennel
305
315
  end
306
316
 
307
317
  # verify query includes critical value
308
- if (query_value = data.fetch(:query)[/\s*[<>]=?\s*(\d+(\.\d+)?)\s*$/, 1])
309
- if Float(query_value) != Float(data.dig(:options, :thresholds, :critical))
310
- invalid! :critical_does_not_match_query, "critical and value used in query must match"
318
+ if (critical = data.dig(:options, :thresholds, :critical))
319
+ if (query_value = data.fetch(:query)[/\s*[<>]=?\s*(\d+(\.\d+)?)\s*$/, 1])
320
+ if Float(query_value) != Float(critical)
321
+ invalid! :critical_does_not_match_query, "critical and value used in query must match"
322
+ end
311
323
  end
312
324
  end
313
325
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "2.11.0"
3
+ VERSION = "2.12.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser