kennel 1.138.1 → 1.139.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/models/dashboard.rb +2 -3
- data/lib/kennel/models/monitor.rb +3 -1
- data/lib/kennel/models/record.rb +1 -1
- data/lib/kennel/models/slo.rb +10 -1
- data/lib/kennel/models/synthetic_test.rb +2 -0
- data/lib/kennel/optional_validations.rb +1 -1
- data/lib/kennel/tags_validation.rb +15 -0
- data/lib/kennel/template_variables.rb +1 -1
- data/lib/kennel/version.rb +1 -1
- data/lib/kennel.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33d7570c6b4d70c6d50f89d0111d8db96e6c0c0ba9273d00bb0975acfef12526
|
4
|
+
data.tar.gz: ea89fdf62138917a204e9c619a7a1182acca1e8d898f22e16707d0a02685cd26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de01f19064531cb09615b63056b1eaa82118a4734fbdd9afa44eef56019923a736b45f9f4440da584cd0939231f7d7928f9a819cbfdb2f014336e82ee0f66c7e
|
7
|
+
data.tar.gz: ec59ee486794d91f5af93e8b3f77134ff206b6f653cc424c3e337b6893fefef1a6fb92a401029e2f5fd4ca83db49c1d284bf556105ad6d38667b3825667bb973
|
@@ -3,6 +3,7 @@ module Kennel
|
|
3
3
|
module Models
|
4
4
|
class Dashboard < Record
|
5
5
|
include TemplateVariables
|
6
|
+
include TagsValidation
|
6
7
|
|
7
8
|
READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [
|
8
9
|
:author_handle, :author_name, :modified_at, :deleted_at, :url, :is_read_only, :notify_list, :restricted_roles
|
@@ -158,7 +159,7 @@ module Kennel
|
|
158
159
|
template_variables: render_template_variables,
|
159
160
|
template_variable_presets: template_variable_presets,
|
160
161
|
widgets: all_widgets,
|
161
|
-
tags: tags.grep(TAG_PREFIX)
|
162
|
+
tags: tags.grep(TAG_PREFIX)
|
162
163
|
)
|
163
164
|
|
164
165
|
json[:reflow_type] = reflow_type if reflow_type # setting nil breaks create with "ordered"
|
@@ -222,8 +223,6 @@ module Kennel
|
|
222
223
|
def validate_json(data)
|
223
224
|
super
|
224
225
|
|
225
|
-
validate_template_variables data
|
226
|
-
|
227
226
|
# Avoid diff from datadog presets sorting.
|
228
227
|
presets = data[:template_variable_presets]
|
229
228
|
if presets && presets != presets.sort_by { |p| p[:name] }
|
@@ -2,6 +2,8 @@
|
|
2
2
|
module Kennel
|
3
3
|
module Models
|
4
4
|
class Monitor < Record
|
5
|
+
include TagsValidation
|
6
|
+
|
5
7
|
RENOTIFY_INTERVALS = [0, 10, 20, 30, 40, 50, 60, 90, 120, 180, 240, 300, 360, 720, 1440].freeze # minutes
|
6
8
|
OPTIONAL_SERVICE_CHECK_THRESHOLDS = [:ok, :warning].freeze
|
7
9
|
READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [
|
@@ -67,7 +69,7 @@ module Kennel
|
|
67
69
|
type: type,
|
68
70
|
query: query.strip,
|
69
71
|
message: message.strip,
|
70
|
-
tags: tags
|
72
|
+
tags: tags,
|
71
73
|
priority: priority,
|
72
74
|
options: {
|
73
75
|
timeout_h: timeout_h,
|
data/lib/kennel/models/record.rb
CHANGED
@@ -162,7 +162,7 @@ module Kennel
|
|
162
162
|
def as_json
|
163
163
|
# A courtesy to those tests that still expect as_json to perform validation and raise on error
|
164
164
|
build if @unfiltered_validation_errors.nil?
|
165
|
-
raise UnvalidatedRecordError, "#{safe_tracking_id} as_json called on invalid part"
|
165
|
+
raise UnvalidatedRecordError, "#{safe_tracking_id} as_json called on invalid part" if filtered_validation_errors.any?
|
166
166
|
|
167
167
|
@as_json
|
168
168
|
end
|
data/lib/kennel/models/slo.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
module Kennel
|
3
3
|
module Models
|
4
4
|
class Slo < Record
|
5
|
+
include TagsValidation
|
6
|
+
|
5
7
|
READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [:type_id, :monitor_tags, :target_threshold, :timeframe, :warning_threshold]
|
6
8
|
TRACKING_FIELD = :description
|
7
9
|
DEFAULTS = {
|
@@ -29,7 +31,7 @@ module Kennel
|
|
29
31
|
description: description,
|
30
32
|
thresholds: thresholds,
|
31
33
|
monitor_ids: monitor_ids,
|
32
|
-
tags: tags
|
34
|
+
tags: tags,
|
33
35
|
type: type
|
34
36
|
)
|
35
37
|
|
@@ -84,6 +86,13 @@ module Kennel
|
|
84
86
|
def validate_json(data)
|
85
87
|
super
|
86
88
|
|
89
|
+
# datadog does not allow uppercase tags for slos
|
90
|
+
bad_tags = data[:tags].grep(/[A-Z]/)
|
91
|
+
if bad_tags.any?
|
92
|
+
invalid! :tags_are_upper_case, "Tags must not be upper case (bad tags: #{bad_tags.sort.inspect})"
|
93
|
+
end
|
94
|
+
|
95
|
+
# warning must be <= critical
|
87
96
|
if data[:thresholds].any? { |t| t[:warning] && t[:warning].to_f <= t[:critical].to_f }
|
88
97
|
invalid! :warning_must_be_gt_critical, "Threshold warning must be greater-than critical value"
|
89
98
|
end
|
@@ -73,7 +73,7 @@ module Kennel
|
|
73
73
|
|
74
74
|
unused_ignores = ignored_errors - unfiltered_validation_errors.map(&:tag)
|
75
75
|
|
76
|
-
|
76
|
+
if unused_ignores.any?
|
77
77
|
to_report << ValidationMessage.new(UNIGNORABLE, "Unused ignores #{unused_ignores.map(&:inspect).sort.uniq.join(" ")}. Remove these from `ignored_errors`")
|
78
78
|
end
|
79
79
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Kennel
|
3
|
+
module TagsValidation
|
4
|
+
def validate_json(data)
|
5
|
+
super
|
6
|
+
|
7
|
+
# ideally we'd avoid duplicated tags, but that happens regularly when importing existing monitors
|
8
|
+
data[:tags] = data[:tags].uniq
|
9
|
+
|
10
|
+
# keep tags clean (TODO: reduce this list)
|
11
|
+
bad_tags = data[:tags].grep(/[^A-Za-z:_0-9.\/*@!#-]/)
|
12
|
+
invalid! :tags_invalid, "Only use A-Za-z:_0-9./*@!#- in tags (bad tags: #{bad_tags.sort.inspect})" if bad_tags.any?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -16,7 +16,7 @@ module Kennel
|
|
16
16
|
|
17
17
|
# check for queries that do not use the variables and would be misleading
|
18
18
|
# TODO: do the same check for apm_query and their group_by
|
19
|
-
def
|
19
|
+
def validate_json(data)
|
20
20
|
variables = (data[:template_variables] || []).map { |v| "$#{v.fetch(:name)}" }
|
21
21
|
return if variables.empty?
|
22
22
|
|
data/lib/kennel/version.rb
CHANGED
data/lib/kennel.rb
CHANGED
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.139.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-
|
11
|
+
date: 2023-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diff-lcs
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/kennel/syncer/plan_displayer.rb
|
117
117
|
- lib/kennel/syncer/resolver.rb
|
118
118
|
- lib/kennel/syncer/types.rb
|
119
|
+
- lib/kennel/tags_validation.rb
|
119
120
|
- lib/kennel/tasks.rb
|
120
121
|
- lib/kennel/template_variables.rb
|
121
122
|
- lib/kennel/unmuted_alerts.rb
|