kennel 1.119.0 → 1.121.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/lib/kennel/filter.rb +27 -14
- data/lib/kennel/models/monitor.rb +20 -1
- data/lib/kennel/version.rb +1 -1
- data/lib/kennel.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb8230c7d3bd7abc24f4c0a1b18de96b7ef892d2f54bdc2ccc010d9ba10a80c6
|
4
|
+
data.tar.gz: b2793e6ac6a79cdb809f77f749b5210501e48bfefb5baa38c2f16ed7043c75ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24d20844e2b74bee9f13c2daf5a80d4a366e7251b826b61e1dd4d5172918cf5fc5b5d694bc7604c7f64d3543150a2f1a8d1884c5c6f462e48b52b74a51267c5f
|
7
|
+
data.tar.gz: 1c52708d519c711b55aa62cb9016ec7124b52634526343ee4140422223e90da351aadd466238bff5e07031dac8b14312cafecde3917e7308193d2c3af9119aeb
|
data/lib/kennel/filter.rb
CHANGED
@@ -2,35 +2,48 @@
|
|
2
2
|
|
3
3
|
module Kennel
|
4
4
|
class Filter
|
5
|
+
attr_reader :project_filter, :tracking_id_filter
|
6
|
+
|
5
7
|
def initialize
|
6
|
-
|
7
|
-
tracking_id_filter
|
8
|
+
# build early so we fail fast on invalid user input
|
9
|
+
@tracking_id_filter = build_tracking_id_filter
|
10
|
+
@project_filter = build_project_filter
|
11
|
+
end
|
12
|
+
|
13
|
+
def filter_projects(projects)
|
14
|
+
filter_resources(projects, :kennel_id, project_filter, "projects", "PROJECT")
|
8
15
|
end
|
9
16
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
def filter_parts(parts)
|
18
|
+
filter_resources(parts, :tracking_id, tracking_id_filter, "resources", "TRACKING_ID")
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def build_project_filter
|
24
|
+
project_names = ENV["PROJECT"]&.split(",")&.sort&.uniq
|
25
|
+
tracking_project_names = tracking_id_filter&.map { |id| id.split(":", 2).first }&.sort&.uniq
|
26
|
+
if project_names && tracking_project_names && project_names != tracking_project_names
|
14
27
|
raise "do not set PROJECT= when using TRACKING_ID="
|
15
28
|
end
|
16
|
-
(
|
29
|
+
(project_names || tracking_project_names)
|
17
30
|
end
|
18
31
|
|
19
|
-
def
|
32
|
+
def build_tracking_id_filter
|
20
33
|
(tracking_id = ENV["TRACKING_ID"]) && tracking_id.split(",").sort.uniq
|
21
34
|
end
|
22
35
|
|
23
|
-
def
|
24
|
-
return unless
|
36
|
+
def filter_resources(resources, by, expected, name, env)
|
37
|
+
return resources unless expected
|
25
38
|
|
26
|
-
|
39
|
+
expected = expected.uniq
|
27
40
|
before = resources.dup
|
28
|
-
resources.select
|
41
|
+
resources = resources.select { |p| expected.include?(p.send(by)) }
|
29
42
|
keeping = resources.uniq(&by).size
|
30
|
-
return if keeping ==
|
43
|
+
return resources if keeping == expected.size
|
31
44
|
|
32
45
|
raise <<~MSG.rstrip
|
33
|
-
#{env}=#{
|
46
|
+
#{env}=#{expected.join(",")} matched #{keeping} #{name}, try any of these:
|
34
47
|
#{before.map(&by).sort.uniq.join("\n")}
|
35
48
|
MSG
|
36
49
|
end
|
@@ -27,11 +27,12 @@ module Kennel
|
|
27
27
|
}.freeze
|
28
28
|
DEFAULT_ESCALATION_MESSAGE = ["", nil].freeze
|
29
29
|
ALLOWED_PRIORITY_CLASSES = [NilClass, Integer].freeze
|
30
|
+
ALLOWED_UNLINKED = [] # rubocop:disable Style/MutableConstant placeholder for custom overrides
|
30
31
|
|
31
32
|
settings(
|
32
33
|
:query, :name, :message, :escalation_message, :critical, :type, :renotify_interval, :warning, :timeout_h, :evaluation_delay,
|
33
34
|
:ok, :no_data_timeframe, :notify_no_data, :notify_audit, :tags, :critical_recovery, :warning_recovery, :require_full_window,
|
34
|
-
:threshold_windows, :new_host_delay, :new_group_delay, :priority
|
35
|
+
:threshold_windows, :new_host_delay, :new_group_delay, :priority, :validate_using_links
|
35
36
|
)
|
36
37
|
|
37
38
|
defaults(
|
@@ -238,6 +239,8 @@ module Kennel
|
|
238
239
|
validate_message_variables(data)
|
239
240
|
end
|
240
241
|
|
242
|
+
validate_using_links(data)
|
243
|
+
|
241
244
|
if type == "service check" && !data[:query].to_s.include?(".by(")
|
242
245
|
invalid! "query must include a .by() at least .by(\"*\")"
|
243
246
|
end
|
@@ -261,6 +264,7 @@ module Kennel
|
|
261
264
|
return if used.empty?
|
262
265
|
used.flatten!(1)
|
263
266
|
used.uniq!
|
267
|
+
used.map! { |w| w.tr("[]", "") }
|
264
268
|
|
265
269
|
# TODO
|
266
270
|
# - also match without by
|
@@ -286,6 +290,21 @@ module Kennel
|
|
286
290
|
Group or filter the query by #{forbidden.map { |f| f.sub(".name", "") }.join(", ")} to use it.
|
287
291
|
MSG
|
288
292
|
end
|
293
|
+
|
294
|
+
def validate_using_links(data)
|
295
|
+
case data[:type]
|
296
|
+
when "composite" # TODO: add slo to mirror resolve_linked_tracking_ids! logic
|
297
|
+
ids = data[:query].tr("-", "_").scan(/\b\d+\b/)
|
298
|
+
ids.reject! { |id| ALLOWED_UNLINKED.include?([tracking_id, id]) }
|
299
|
+
if ids.any?
|
300
|
+
invalid! <<~MSG.rstrip
|
301
|
+
Used #{ids} in the query, but should only use links in the form of %{<project id>:<monitor id>}
|
302
|
+
If that is not possible, add `validate_using_links: ->(*){} # linked monitors are not in kennel
|
303
|
+
MSG
|
304
|
+
end
|
305
|
+
else # do nothing
|
306
|
+
end
|
307
|
+
end
|
289
308
|
end
|
290
309
|
end
|
291
310
|
end
|
data/lib/kennel/version.rb
CHANGED
data/lib/kennel.rb
CHANGED
@@ -101,10 +101,10 @@ module Kennel
|
|
101
101
|
@generated ||= begin
|
102
102
|
Progress.progress "Generating" do
|
103
103
|
projects = projects_provider.projects
|
104
|
-
|
104
|
+
projects = filter.filter_projects projects
|
105
105
|
|
106
106
|
parts = Utils.parallel(projects, &:validated_parts).flatten(1)
|
107
|
-
|
107
|
+
parts = filter.filter_parts parts
|
108
108
|
|
109
109
|
parts.group_by(&:tracking_id).each do |tracking_id, same|
|
110
110
|
next if same.size == 1
|
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.
|
4
|
+
version: 1.121.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: 2022-09-
|
11
|
+
date: 2022-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diff-lcs
|