kennel 2.10.0 → 2.11.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: 9213ac86e78dd85ff280d2048bd20fe3d074c3d6218cc45021b8c11eee7c720c
4
- data.tar.gz: b2506ab43bb450a0496db0985ffa990b378ad591fa7be2a1c8db32223863680e
3
+ metadata.gz: 88495b67d113181455cb6dc751d2f7820eababca5679cfb714bb614dc9370ad6
4
+ data.tar.gz: a8703613913aa4557c585e605f35a1aef9555902c65a5f1c1772b1038e9d4d34
5
5
  SHA512:
6
- metadata.gz: 73331755a7074cd0eeb95c92901cb8bf477380672a553cd7ef4722ec4cb6ea6f2fd56634eef442fb4a59de961d102c7b8b0f5b39788d006c24d960573eb27500
7
- data.tar.gz: fa9ee34a57cce815f63eba43208daac2232cd04456f1200adc4181e6a381407b93962d52cbc5f9b27398caa863c8ab371758f5c216613b0218f8b9e958de6bc5
6
+ metadata.gz: d730ee50ff704f25eb39fdd8daa9c95a2c0b43f9a9534c7f1a05a245bd3881ab5ce36f12ebf226354eeafe94c4a961e843eebbbcf0312b2b548577b26a4debdd
7
+ data.tar.gz: ff487e51479e7a463464e37ec09a10ef7c1dc7d695bcf18f97303048ab0a75759d71eda14aa95e512aa69b66c25baf016d778be449455c0ef069e081f5957373
@@ -6,7 +6,8 @@ module Kennel
6
6
 
7
7
  OPTIONAL_SERVICE_CHECK_THRESHOLDS = [:ok, :warning].freeze
8
8
  READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [
9
- :multi, :matching_downtimes, :overall_state_modified, :overall_state, :restricted_roles, :draft_status, :assets
9
+ :multi, :matching_downtimes, :overall_state_modified, :overall_state, :restricted_roles, :draft_status, :assets,
10
+ :enable_logs_sample
10
11
  ]
11
12
  TRACKING_FIELD = :message
12
13
 
@@ -25,7 +26,7 @@ module Kennel
25
26
  group_retention_duration: nil,
26
27
  groupby_simple_monitor: false,
27
28
  variables: nil,
28
- on_missing_data: "default", # "default" is "evaluate as zero"
29
+ on_missing_data: nil,
29
30
  notification_preset_name: nil,
30
31
  notify_by: nil
31
32
  }.freeze
@@ -74,6 +75,8 @@ module Kennel
74
75
  )
75
76
 
76
77
  def build_json
78
+ no_data_options = configure_no_data
79
+
77
80
  data = super.merge(
78
81
  name: "#{name}#{LOCK}",
79
82
  type: type,
@@ -83,8 +86,7 @@ module Kennel
83
86
  priority: priority,
84
87
  options: {
85
88
  timeout_h: timeout_h,
86
- notify_no_data: notify_no_data,
87
- no_data_timeframe: notify_no_data ? no_data_timeframe : nil,
89
+ **no_data_options.except(:on_missing_data),
88
90
  notify_audit: notify_audit,
89
91
  require_full_window: require_full_window,
90
92
  new_host_delay: new_host_delay,
@@ -92,33 +94,14 @@ module Kennel
92
94
  include_tags: true,
93
95
  escalation_message: Utils.presence(escalation_message.strip),
94
96
  evaluation_delay: evaluation_delay,
95
- locked: false, # deprecated: setting this to true will likely fail
96
97
  renotify_interval: renotify_interval || 0,
97
- variables: variables
98
+ variables: variables,
99
+ **configure_thresholds,
100
+ **no_data_options.slice(:on_missing_data) # moved here to avoid generated diff
98
101
  }
99
102
  )
100
103
 
101
104
  options = data[:options]
102
- if data.fetch(:type) != "composite"
103
- thresholds = (options[:thresholds] = { critical: critical })
104
-
105
- # warning, ok, critical_recovery, and warning_recovery are optional
106
- [:warning, :ok, :critical_recovery, :warning_recovery].each do |key|
107
- if (value = send(key))
108
- thresholds[key] = value
109
- end
110
- end
111
-
112
- thresholds[:critical] = critical unless
113
- case data.fetch(:type)
114
- when "service check"
115
- # avoid diff for default values of 1
116
- OPTIONAL_SERVICE_CHECK_THRESHOLDS.each { |t| thresholds[t] ||= 1 }
117
- when "query alert"
118
- # metric and query values are stored as float by datadog
119
- thresholds.each { |k, v| thresholds[k] = Float(v) }
120
- end
121
- end
122
105
 
123
106
  # set without causing lots of nulls to be stored
124
107
  if (notify_by_value = notify_by)
@@ -149,30 +132,37 @@ module Kennel
149
132
  # Add in statuses where we would re notify on. Possible values: alert, no data, warn
150
133
  if options[:renotify_interval] != 0
151
134
  statuses = ["alert"]
152
- statuses << "no data" if options[:notify_no_data]
135
+ statuses << "no data" if options[:notify_no_data] || options[:on_missing_data] == "show_and_notify_no_data"
153
136
  statuses << "warn" if options.dig(:thresholds, :warning)
154
137
  options[:renotify_statuses] = statuses
155
138
  end
156
139
 
157
- # on_missing_data cannot be used with notify_no_data or no_data_timeframe
158
- # TODO migrate everything to only use on_missing_data
159
- if data.fetch(:type) == "event-v2 alert" || on_missing_data != "default"
160
- options[:on_missing_data] = on_missing_data
161
- options[:notify_no_data] = false # cannot set nil or it's an endless update loop
162
- options.delete :no_data_timeframe
163
- end
164
-
165
140
  # only set when needed to avoid big diff
166
141
  if (notification_preset_name = notification_preset_name())
167
142
  options[:notification_preset_name] = notification_preset_name
168
143
  end
169
144
 
170
- # locked is deprecated, will fail if used
171
- options.delete :locked
172
-
173
145
  data
174
146
  end
175
147
 
148
+ # TODO: migrate everything to only use on_missing_data by only sending notify_no_data when it was set by a user
149
+ # and enforce that it is not set at the same time as on_missing_data
150
+ def configure_no_data
151
+ notify = notify_no_data
152
+ action = on_missing_data
153
+
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
+ { on_missing_data: action || "default" }
158
+ else
159
+ {
160
+ notify_no_data: notify,
161
+ no_data_timeframe: notify ? no_data_timeframe : nil
162
+ }
163
+ end
164
+ end
165
+
176
166
  def resolve_linked_tracking_ids!(id_map, **args)
177
167
  case as_json[:type]
178
168
  when "composite", "slo alert"
@@ -206,7 +196,8 @@ module Kennel
206
196
  # validate that monitors that alert on no data resolve in external services by using timeout_h, so it sends a
207
197
  # notification when the no data group is removed from the monitor, which datadog does automatically after 24h
208
198
  def timeout_h
209
- notify_no_data && on_missing_data != "resolve" ? 24 : MONITOR_OPTION_DEFAULTS.fetch(:timeout_h)
199
+ sending_no_data_notifications = (on_missing_data ? on_missing_data == "show_and_notify_no_data" : notify_no_data)
200
+ sending_no_data_notifications ? 24 : MONITOR_OPTION_DEFAULTS.fetch(:timeout_h)
210
201
  end
211
202
 
212
203
  def self.api_resource
@@ -235,7 +226,9 @@ module Kennel
235
226
  ignore_default(expected, actual, MONITOR_DEFAULTS)
236
227
 
237
228
  options = actual.fetch(:options)
238
- options.delete(:silenced) # we do not manage silenced, so ignore it when diffing
229
+
230
+ # we do not manage silenced: ignore it when diffing
231
+ options.delete(:silenced)
239
232
 
240
233
  # fields are not returned when set to true
241
234
  if ["service check", "event alert"].include?(actual[:type])
@@ -265,13 +258,38 @@ module Kennel
265
258
  options.delete(:escalation_message)
266
259
  expected_options.delete(:escalation_message)
267
260
  end
261
+
268
262
  # locked is deprecated: ignored when diffing
269
263
  options.delete(:locked)
270
- expected_options.delete(:locked)
271
264
  end
272
265
 
273
266
  private
274
267
 
268
+ def configure_thresholds
269
+ return {} if type == "composite"
270
+
271
+ thresholds = { critical: critical }
272
+
273
+ # set optional variables
274
+ [:warning, :ok, :critical_recovery, :warning_recovery].each do |key|
275
+ if (value = send(key))
276
+ thresholds[key] = value
277
+ end
278
+ end
279
+
280
+ # custom logic for some types
281
+ case type
282
+ when "service check"
283
+ # avoid diff for default values of 1
284
+ OPTIONAL_SERVICE_CHECK_THRESHOLDS.each { |t| thresholds[t] ||= 1 }
285
+ when "query alert"
286
+ # metric and query values are stored as float by datadog
287
+ thresholds.each { |k, v| thresholds[k] = Float(v) }
288
+ end
289
+
290
+ { thresholds: thresholds }
291
+ end
292
+
275
293
  def validate_json(data)
276
294
  super
277
295
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "2.10.0"
3
+ VERSION = "2.11.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.0
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-08 00:00:00.000000000 Z
11
+ date: 2026-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs