kennel 1.140.0 → 1.142.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8a15178bd108647314171a012bafa0c977f998a8488418c0d323de095e0a1b3
4
- data.tar.gz: 1673aec908b72090afa31e0b3dd8a923dbf505c01ab2f5dfd6211846edab4f7d
3
+ metadata.gz: 4d3462f8e8c88a8faab007c9d65f799703152083c59f9b1f726eb7f958efb743
4
+ data.tar.gz: f24f0df2e733292cb32cedfe257cb7393b8403f35585ede6fb008fd9e7668bb4
5
5
  SHA512:
6
- metadata.gz: 0343af2d0a40081a7fd8ffe5bb9932344f75ef91f1b688f4b6e4eb72a0bd5f59c9b67cf72f498bb008f76aae7f6df645b0bcd8258b5c1c892cb8cd3ef21cc468
7
- data.tar.gz: 3a1f1df7f6195ec235713dc173e8c869013654355432159e1bd1e59dd29ea3d849407ee9cf43f31453411a54224ae1ea8b80bc1e01e209176d0cfe28f8fc2bc3
6
+ metadata.gz: 75b7f56baabbffc696d44acae8d08277afd499fd1915f1f268a7ffd9010ff9fc6f1ae59c06f54a78d1b3e49829d9ec61f0d98fd16ac00d85ef494451339fe3e2
7
+ data.tar.gz: a5c96201475a76c9712313cbfc1bfbd629f87748d2d8d101dc3413ebc72a5399b18291df8fab64f6162c3e534fda17f6069d12fd380fc2c5e32c635f7a8bab13
data/Readme.md CHANGED
@@ -28,6 +28,7 @@ end
28
28
  class Bar < Kennel::Models::Project
29
29
  defaults(
30
30
  team: -> { Teams::Foo.new }, # use mention and tags from the team
31
+ tags: -> { super() + ["project:bar"] }, # unique tag for all project components
31
32
  parts: -> {
32
33
  [
33
34
  Kennel::Models::Monitor.new(
@@ -30,12 +30,11 @@ module Kennel
30
30
  }.freeze
31
31
  DEFAULT_ESCALATION_MESSAGE = ["", nil].freeze
32
32
  ALLOWED_PRIORITY_CLASSES = [NilClass, Integer].freeze
33
- ALLOWED_UNLINKED = [] # rubocop:disable Style/MutableConstant placeholder for custom overrides
34
33
 
35
34
  settings(
36
35
  :query, :name, :message, :escalation_message, :critical, :type, :renotify_interval, :warning, :timeout_h, :evaluation_delay,
37
36
  :ok, :no_data_timeframe, :notify_no_data, :notify_audit, :tags, :critical_recovery, :warning_recovery, :require_full_window,
38
- :threshold_windows, :scheduling_options, :new_host_delay, :new_group_delay, :priority, :validate_using_links, :variables, :on_missing_data,
37
+ :threshold_windows, :scheduling_options, :new_host_delay, :new_group_delay, :priority, :variables, :on_missing_data,
39
38
  :notification_preset_name
40
39
  )
41
40
 
@@ -265,6 +264,7 @@ module Kennel
265
264
  end
266
265
 
267
266
  validate_using_links(data)
267
+ validate_thresholds(data)
268
268
 
269
269
  if type == "service check" && !data[:query].to_s.include?(".by(")
270
270
  invalid! :query_must_include_by, "query must include a .by() at least .by(\"*\")"
@@ -320,16 +320,45 @@ module Kennel
320
320
  case data[:type]
321
321
  when "composite" # TODO: add slo to mirror resolve_linked_tracking_ids! logic
322
322
  ids = data[:query].tr("-", "_").scan(/\b\d+\b/)
323
- ids.reject! { |id| ALLOWED_UNLINKED.include?([tracking_id, id]) }
324
323
  if ids.any?
325
324
  invalid! :links_must_be_via_tracking_id, <<~MSG.rstrip
326
- Used #{ids} in the query, but should only use links in the form of %{<project id>:<monitor id>}
327
- If that is not possible, add `validate_using_links: ->(*){} # linked monitors are not in kennel
325
+ Use kennel ids in the query for linking monitors instead of #{ids}, for example `%{#{project.kennel_id}:<monitor id>}`
326
+ If the target monitors are not managed via kennel, add `ignored_errors: [:links_must_be_via_tracking_id] # linked monitors are not in kennel`
327
+ MSG
328
+ end
329
+ when "slo alert"
330
+ if (id = data[:query][/error_budget\("([a-f\d]+)"\)/, 1])
331
+ invalid! :links_must_be_via_tracking_id, <<~MSG
332
+ Use kennel ids in the query for linking alerts to slos instead of "#{id}", for example `error_budget("%{#{project.kennel_id}:slo_id_goes_here}")
333
+ If the target slo is not managed by kennel, then add `ignored_errors: [:links_must_be_via_tracking_id] # linked slo is not in kennel`
328
334
  MSG
329
335
  end
330
336
  else # do nothing
331
337
  end
332
338
  end
339
+
340
+ # Prevent "Warning threshold (50.0) must be less than the alert threshold (20.0) with > comparison."
341
+ def validate_thresholds(data)
342
+ return unless (warning = data.dig(:options, :thresholds, :warning))
343
+ critical = data.dig(:options, :thresholds, :critical)
344
+
345
+ case data[:query]
346
+ when /<=?\s*\S+\s*$/
347
+ if warning <= critical
348
+ invalid!(
349
+ :alert_less_than_warning,
350
+ "Warning threshold (#{warning}) must be greater than the alert threshold (#{critical}) with < comparison"
351
+ )
352
+ end
353
+ when />=?\s*\S+\s*$/
354
+ if warning >= critical
355
+ invalid!(
356
+ :alert_less_than_warning,
357
+ "Warning threshold (#{warning}) must be less than the alert threshold (#{critical}) with > comparison"
358
+ )
359
+ end
360
+ end
361
+ end
333
362
  end
334
363
  end
335
364
  end
@@ -4,7 +4,7 @@ module Kennel
4
4
  class Project < Base
5
5
  settings :team, :parts, :tags, :mention, :name, :kennel_id
6
6
  defaults(
7
- tags: -> { ["service:#{kennel_id}"] + team.tags },
7
+ tags: -> { team.tags },
8
8
  mention: -> { team.mention }
9
9
  )
10
10
 
@@ -92,6 +92,14 @@ module Kennel
92
92
  invalid! :tags_are_upper_case, "Tags must not be upper case (bad tags: #{bad_tags.sort.inspect})"
93
93
  end
94
94
 
95
+ # prevent "Invalid payload: The target is incorrect: target must be a positive number between (0.0, 100.0)"
96
+ data[:thresholds]&.each do |threshold|
97
+ target = threshold.fetch(:target)
98
+ if !target || target <= 0 || target >= 100
99
+ invalid! :threshold_target_invalid, "SLO threshold target must be > 0 and < 100"
100
+ end
101
+ end
102
+
95
103
  # warning must be <= critical
96
104
  if data[:thresholds].any? { |t| t[:warning] && t[:warning].to_f <= t[:critical].to_f }
97
105
  invalid! :warning_must_be_gt_critical, "Threshold warning must be greater-than critical value"
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.140.0"
3
+ VERSION = "1.142.0"
4
4
  end
data/template/Readme.md CHANGED
@@ -28,6 +28,7 @@ end
28
28
  class Bar < Kennel::Models::Project
29
29
  defaults(
30
30
  team: -> { Teams::Foo.new }, # use mention and tags from the team
31
+ tags: -> { super() + ["project:bar"] }, # unique tag for all project components
31
32
  parts: -> {
32
33
  [
33
34
  Kennel::Models::Monitor.new(
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: 1.140.0
4
+ version: 1.142.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: 2023-05-30 00:00:00.000000000 Z
11
+ date: 2023-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs