kennel 1.85.0 → 1.87.1
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/importer.rb +7 -1
- data/lib/kennel/models/dashboard.rb +76 -37
- data/lib/kennel/models/slo.rb +1 -1
- data/lib/kennel/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 42e4d1fd80bfa23ccbed32dcc6cfeb05fda2a2748bc29b302e6f982273302551
|
|
4
|
+
data.tar.gz: 6ffc6ddafa5518868cc913fd05add8f11eb49729ba4ca498b357241ab80111f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76f2b875dd8e918db62b0ee13a6ad01acd6a187f11127824176cdee2f8665ec0ffa4d5ad3a0f8fbfd97fbf980faae8039cdbca8f2b078ef81e091a9a34c3ed0e
|
|
7
|
+
data.tar.gz: a612a2d02f684f847ef6c167d2a3ef9fc815f80c1fd618106c8824017cede188c77dec3700d1a7afd46c481cd3c8fa7c37358af6a9737c1703a68491d159a5b1
|
data/lib/kennel/importer.rb
CHANGED
|
@@ -60,10 +60,16 @@ module Kennel
|
|
|
60
60
|
query.sub!(/([><=]) (#{Regexp.escape(critical.to_f.to_s)}|#{Regexp.escape(critical.to_i.to_s)})$/, "\\1 \#{critical}")
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
# using float in query is not allowed, so convert here
|
|
64
|
+
data[:critical] = data[:critical].to_i if data[:type] == "event alert"
|
|
65
|
+
|
|
63
66
|
data[:type] = "query alert" if data[:type] == "metric alert"
|
|
64
67
|
when "dashboard"
|
|
65
68
|
widgets = data[:widgets]&.flat_map { |widget| widget.dig(:definition, :widgets) || [widget] }
|
|
66
|
-
widgets&.each
|
|
69
|
+
widgets&.each do |widget|
|
|
70
|
+
dry_up_query!(widget)
|
|
71
|
+
(widget.dig(:definition, :markers) || []).each { |m| m[:label]&.delete! " " }
|
|
72
|
+
end
|
|
67
73
|
end
|
|
68
74
|
|
|
69
75
|
data.delete(:tags) if data[:tags] == [] # do not create super + [] call
|
|
@@ -12,14 +12,61 @@ module Kennel
|
|
|
12
12
|
style: { line_width: "normal", palette: "dog_classic", line_type: "solid" }
|
|
13
13
|
}.freeze
|
|
14
14
|
WIDGET_DEFAULTS = {
|
|
15
|
-
"timeseries" => {
|
|
16
|
-
|
|
15
|
+
"timeseries" => {
|
|
16
|
+
legend_size: "0",
|
|
17
|
+
markers: [],
|
|
18
|
+
legend_columns: [
|
|
19
|
+
"avg",
|
|
20
|
+
"min",
|
|
21
|
+
"max",
|
|
22
|
+
"value",
|
|
23
|
+
"sum"
|
|
24
|
+
],
|
|
25
|
+
legend_layout: "auto",
|
|
26
|
+
yaxis: {
|
|
27
|
+
include_zero: true,
|
|
28
|
+
label: "",
|
|
29
|
+
scale: "linear",
|
|
30
|
+
min: "auto",
|
|
31
|
+
max: "auto"
|
|
32
|
+
},
|
|
33
|
+
show_legend: true,
|
|
34
|
+
time: {},
|
|
35
|
+
title_align: "left",
|
|
36
|
+
title_size: "16"
|
|
37
|
+
},
|
|
38
|
+
"note" => {
|
|
39
|
+
show_tick: false,
|
|
40
|
+
tick_edge: "left",
|
|
41
|
+
tick_pos: "50%",
|
|
42
|
+
text_align: "left",
|
|
43
|
+
has_padding: true,
|
|
44
|
+
background_color: "white",
|
|
45
|
+
font_size: "14"
|
|
46
|
+
},
|
|
47
|
+
"query_value" => {
|
|
48
|
+
autoscale: true,
|
|
49
|
+
time: {},
|
|
50
|
+
title_align: "left",
|
|
51
|
+
title_size: "16"
|
|
52
|
+
},
|
|
53
|
+
"free_text" => {
|
|
54
|
+
font_size: "auto"
|
|
55
|
+
},
|
|
56
|
+
"check_status" => {
|
|
57
|
+
title_align: "left",
|
|
58
|
+
title_size: "16"
|
|
59
|
+
},
|
|
60
|
+
"slo" => {
|
|
61
|
+
global_time_target: "0",
|
|
62
|
+
title_align: "left",
|
|
63
|
+
title_size: "16"
|
|
64
|
+
}
|
|
17
65
|
}.freeze
|
|
18
66
|
SUPPORTED_DEFINITION_OPTIONS = [:events, :markers, :precision].freeze
|
|
19
67
|
|
|
20
68
|
DEFAULTS = {
|
|
21
|
-
template_variable_presets: nil
|
|
22
|
-
reflow_type: "auto"
|
|
69
|
+
template_variable_presets: nil
|
|
23
70
|
}.freeze
|
|
24
71
|
|
|
25
72
|
settings :title, :description, :definitions, :widgets, :layout_type, :template_variable_presets, :reflow_type
|
|
@@ -29,7 +76,7 @@ module Kennel
|
|
|
29
76
|
definitions: -> { [] },
|
|
30
77
|
widgets: -> { [] },
|
|
31
78
|
template_variable_presets: -> { DEFAULTS.fetch(:template_variable_presets) },
|
|
32
|
-
reflow_type: -> {
|
|
79
|
+
reflow_type: -> { layout_type == "ordered" ? "auto" : nil },
|
|
33
80
|
id: -> { nil }
|
|
34
81
|
)
|
|
35
82
|
|
|
@@ -41,52 +88,43 @@ module Kennel
|
|
|
41
88
|
def normalize(expected, actual)
|
|
42
89
|
super
|
|
43
90
|
|
|
44
|
-
ignore_default
|
|
91
|
+
ignore_default expected, actual, DEFAULTS
|
|
92
|
+
ignore_default expected, actual, reflow_type: "auto" if expected[:layout_type] == "ordered"
|
|
45
93
|
|
|
46
94
|
widgets_pairs(expected, actual).each do |pair|
|
|
47
|
-
|
|
48
|
-
pair
|
|
49
|
-
widgets.each do |widget|
|
|
50
|
-
if formats = widget.dig(:definition, :conditional_formats)
|
|
51
|
-
widget[:definition][:conditional_formats] = formats.sort_by(&:hash)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
ignore_widget_defaults pair
|
|
57
|
-
|
|
95
|
+
pair.each { |w| sort_conditional_formats w }
|
|
96
|
+
ignore_widget_defaults(*pair)
|
|
58
97
|
ignore_request_defaults(*pair)
|
|
59
|
-
|
|
60
|
-
# ids are kinda random so we always discard them
|
|
61
|
-
pair.each { |widgets| widgets.each { |w| w.delete(:id) } }
|
|
98
|
+
pair.each { |widget| widget&.delete(:id) } # ids are kinda random so we always discard them
|
|
62
99
|
end
|
|
63
100
|
end
|
|
64
101
|
|
|
65
102
|
private
|
|
66
103
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
next unless defaults = WIDGET_DEFAULTS[types.first]
|
|
72
|
-
ignore_defaults(pair[0], pair[1], defaults, nesting: :definition)
|
|
104
|
+
# conditional_formats ordering is randomly changed by datadog, compare a stable ordering
|
|
105
|
+
def sort_conditional_formats(widget)
|
|
106
|
+
if formats = widget&.dig(:definition, :conditional_formats)
|
|
107
|
+
widget[:definition][:conditional_formats] = formats.sort_by(&:hash)
|
|
73
108
|
end
|
|
74
109
|
end
|
|
75
110
|
|
|
111
|
+
def ignore_widget_defaults(expected, actual)
|
|
112
|
+
types = [expected&.dig(:definition, :type), actual&.dig(:definition, :type)].uniq.compact
|
|
113
|
+
return unless types.size == 1
|
|
114
|
+
return unless defaults = WIDGET_DEFAULTS[types.first]
|
|
115
|
+
ignore_default expected&.[](:definition) || {}, actual&.[](:definition) || {}, defaults
|
|
116
|
+
end
|
|
117
|
+
|
|
76
118
|
# discard styles/conditional_formats/aggregator if nothing would change when we applied (both are default or nil)
|
|
77
119
|
def ignore_request_defaults(expected, actual)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
ignore_defaults e_r, a_r, REQUEST_DEFAULTS
|
|
82
|
-
end
|
|
120
|
+
a_r = actual&.dig(:definition, :requests) || []
|
|
121
|
+
e_r = expected&.dig(:definition, :requests) || []
|
|
122
|
+
ignore_defaults e_r, a_r, REQUEST_DEFAULTS
|
|
83
123
|
end
|
|
84
124
|
|
|
85
|
-
def ignore_defaults(expected, actual, defaults
|
|
125
|
+
def ignore_defaults(expected, actual, defaults)
|
|
86
126
|
[expected.size, actual.size].max.times do |i|
|
|
87
|
-
|
|
88
|
-
a = actual.dig(i, *nesting) || {}
|
|
89
|
-
ignore_default(e, a, defaults)
|
|
127
|
+
ignore_default expected[i] || {}, actual[i] || {}, defaults
|
|
90
128
|
end
|
|
91
129
|
end
|
|
92
130
|
|
|
@@ -99,7 +137,7 @@ module Kennel
|
|
|
99
137
|
nested = pair.map { |d| d.dig(:widgets, i, :definition, :widgets) || [] }
|
|
100
138
|
result << nested if nested.any?(&:any?)
|
|
101
139
|
end
|
|
102
|
-
result
|
|
140
|
+
result.flat_map { |a, e| [a.size, e.size].max.times.map { |i| [a[i], e[i]] } }
|
|
103
141
|
end
|
|
104
142
|
end
|
|
105
143
|
|
|
@@ -112,12 +150,13 @@ module Kennel
|
|
|
112
150
|
layout_type: layout_type,
|
|
113
151
|
title: "#{title}#{LOCK}",
|
|
114
152
|
description: description,
|
|
115
|
-
reflow_type: reflow_type,
|
|
116
153
|
template_variables: render_template_variables,
|
|
117
154
|
template_variable_presets: template_variable_presets,
|
|
118
155
|
widgets: all_widgets
|
|
119
156
|
}
|
|
120
157
|
|
|
158
|
+
@json[:reflow_type] = reflow_type if reflow_type # setting nil breaks create with "ordered"
|
|
159
|
+
|
|
121
160
|
@json[:id] = id if id
|
|
122
161
|
|
|
123
162
|
validate_json(@json) if validate
|
data/lib/kennel/models/slo.rb
CHANGED
data/lib/kennel/version.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.87.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Grosser
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -94,14 +94,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
94
94
|
requirements:
|
|
95
95
|
- - ">="
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
|
-
version: 2.
|
|
97
|
+
version: 2.6.0
|
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
|
100
100
|
- - ">="
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
102
|
version: '0'
|
|
103
103
|
requirements: []
|
|
104
|
-
rubygems_version: 3.
|
|
104
|
+
rubygems_version: 3.2.16
|
|
105
105
|
signing_key:
|
|
106
106
|
specification_version: 4
|
|
107
107
|
summary: Keep datadog monitors/dashboards/etc in version control, avoid chaotic management
|