kennel 1.76.2 → 1.78.2
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/Readme.md +10 -0
- data/lib/kennel/api.rb +4 -1
- data/lib/kennel/models/dashboard.rb +1 -1
- data/lib/kennel/models/monitor.rb +14 -7
- data/lib/kennel/models/slo.rb +1 -0
- data/lib/kennel/syncer.rb +4 -3
- data/lib/kennel/template_variables.rb +13 -9
- data/lib/kennel/version.rb +1 -1
- data/template/Readme.md +10 -0
- 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: 404c565dc87a8ffd30f1c0293228cc5270bedd3c6e5eaae1d191ba6cdae60ce7
|
4
|
+
data.tar.gz: 274f807772d6077c625a503aeb3d98edeef795bf0d7c40845db56d7b2e2e2ff0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b165262ab6d8f6e8efadff786d3829a75e96d6893e4235eed961ef5203c66d0f250488e7911964a77c2862df0e196e08619582ce9cda51fed851141785a0a9c4
|
7
|
+
data.tar.gz: ab59bfdd4ca2d73526fb28126fd1f18765ce92703d7bad71c05d7f321f54fa39192db87ad4a7ae65c12441e38eb794264bceae8aad57be84e30a2c06ac65b3f5
|
data/Readme.md
CHANGED
@@ -198,6 +198,15 @@ end
|
|
198
198
|
end
|
199
199
|
```
|
200
200
|
|
201
|
+
### Updating existing resources with id
|
202
|
+
|
203
|
+
Setting `id` makes kennel take over a manually created datadog resource.
|
204
|
+
When manually creating to import, it is best to remove the `id` and delete the manually created resource.
|
205
|
+
|
206
|
+
When an `id` is set and the original resource is deleted, kennel will fail to update,
|
207
|
+
removing the `id` will cause kennel to create a new resource in datadog.
|
208
|
+
|
209
|
+
|
201
210
|
### Skipping validations
|
202
211
|
|
203
212
|
Some validations might be too strict for your usecase or just wrong, please [open an issue](https://github.com/grosser/kennel/issues) and
|
@@ -210,6 +219,7 @@ To link to existing monitors via their kennel_id `projects kennel_id` + `:` + `m
|
|
210
219
|
- Screens `uptime` widgets can use `monitor: {id: "foo:bar"}`
|
211
220
|
- Screens `alert_graph` widgets can use `alert_id: "foo:bar"`
|
212
221
|
- Monitors `composite` can use `query: -> { "%{foo:bar} || %{foo:baz}" }`
|
222
|
+
- Slos can use `monitor_ids: -> ["foo:bar"]`
|
213
223
|
|
214
224
|
### Debugging changes locally
|
215
225
|
|
data/lib/kennel/api.rb
CHANGED
@@ -42,8 +42,11 @@ module Kennel
|
|
42
42
|
request :put, "/api/v1/#{api_resource}/#{id}", body: attributes
|
43
43
|
end
|
44
44
|
|
45
|
+
# - force=true to not dead-lock on dependent monitors+slos
|
46
|
+
# external dependency on kennel managed resources is their problem, we don't block on it
|
47
|
+
# (?force=true did not work, force for dashboard is not documented but does not blow up)
|
45
48
|
def delete(api_resource, id)
|
46
|
-
request :delete, "/api/v1/#{api_resource}/#{id}", ignore_404: true
|
49
|
+
request :delete, "/api/v1/#{api_resource}/#{id}", params: { force: "true" }, ignore_404: true
|
47
50
|
end
|
48
51
|
|
49
52
|
private
|
@@ -192,7 +192,7 @@ module Kennel
|
|
192
192
|
end
|
193
193
|
|
194
194
|
if type == "query alert"
|
195
|
-
# verify interval is
|
195
|
+
# verify interval is valid
|
196
196
|
interval = data.fetch(:query)[/\(last_(\S+?)\)/, 1]
|
197
197
|
if interval && !QUERY_INTERVALS.include?(interval)
|
198
198
|
invalid! "query interval was #{interval}, but must be one of #{QUERY_INTERVALS.join(", ")}"
|
@@ -200,13 +200,20 @@ module Kennel
|
|
200
200
|
end
|
201
201
|
|
202
202
|
if ["query alert", "service check"].include?(type) # TODO: most likely more types need this
|
203
|
-
# verify is_match uses available variables
|
203
|
+
# verify is_match/is_exact_match uses available variables
|
204
204
|
message = data.fetch(:message)
|
205
|
-
used = message.scan(/{{\s
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
205
|
+
used = message.scan(/{{\s*([#^]is(?:_exact)?_match)\s*([^\s}]+)/)
|
206
|
+
if used.any?
|
207
|
+
allowed = data.fetch(:query)[/by\s*[({]([^})]+)[})]/, 1]
|
208
|
+
.to_s.gsub(/["']/, "").split(/\s*,\s*/)
|
209
|
+
.map! { |w| %("#{w}.name") }
|
210
|
+
used.uniq.each do |match, group|
|
211
|
+
next if allowed.include?(group)
|
212
|
+
invalid!(
|
213
|
+
"#{match} used with #{group}, but can only be used with #{allowed.join(", ")}. " \
|
214
|
+
"Group the query by #{group.sub(".name", "").tr('"', "")} or change the #{match}"
|
215
|
+
)
|
216
|
+
end
|
210
217
|
end
|
211
218
|
end
|
212
219
|
end
|
data/lib/kennel/models/slo.rb
CHANGED
@@ -67,6 +67,7 @@ module Kennel
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def resolve_linked_tracking_ids!(id_map, **args)
|
70
|
+
return unless as_json[:monitor_ids] # ignore_default can remove it
|
70
71
|
as_json[:monitor_ids] = as_json[:monitor_ids].map do |id|
|
71
72
|
id.is_a?(String) ? resolve_link(id, :monitor, id_map, **args) : id
|
72
73
|
end
|
data/lib/kennel/syncer.rb
CHANGED
@@ -38,7 +38,7 @@ module Kennel
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def update
|
41
|
-
changed = (@create + @update).map { |_, e| e }
|
41
|
+
changed = (@create + @update).map { |_, e| e }
|
42
42
|
|
43
43
|
@create.each do |_, e|
|
44
44
|
e.resolve_linked_tracking_ids!({}, force: true)
|
@@ -139,7 +139,8 @@ module Kennel
|
|
139
139
|
def ensure_all_ids_found
|
140
140
|
@expected.each do |e|
|
141
141
|
next unless id = e.id
|
142
|
-
|
142
|
+
resource = e.class.api_resource
|
143
|
+
raise "Unable to find existing #{resource} with id #{id}\nIf the #{resource} was deleted, remove the `id: -> { #{e.id} }` line."
|
143
144
|
end
|
144
145
|
end
|
145
146
|
|
@@ -188,7 +189,7 @@ module Kennel
|
|
188
189
|
end
|
189
190
|
|
190
191
|
# Do not add tracking-id when working with existing ids on a branch,
|
191
|
-
# so resource do not get deleted
|
192
|
+
# so resource do not get deleted from running an update on master (for example merge->CI).
|
192
193
|
# Also make sure the diff still makes sense, by kicking out the now noop-update.
|
193
194
|
#
|
194
195
|
# Note: ideally we'd never add tracking in the first place, but at that point we do not know the diff yet
|
@@ -16,18 +16,22 @@ 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 validate_template_variables(data
|
19
|
+
def validate_template_variables(data)
|
20
20
|
variables = (data[:template_variables] || []).map { |v| "$#{v.fetch(:name)}" }
|
21
|
-
|
21
|
+
return if variables.empty?
|
22
|
+
|
23
|
+
queries = data[:widgets].flat_map do |widget|
|
22
24
|
([widget] + (widget.dig(:definition, :widgets) || [])).flat_map { |w| widget_queries(w) }
|
23
25
|
end.compact
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
|
27
|
+
matches = variables.map { |v| Regexp.new "#{Regexp.escape(v)}\\b" }
|
28
|
+
queries.reject! { |q| matches.all? { |m| q.match? m } }
|
29
|
+
return if queries.empty?
|
30
|
+
|
31
|
+
invalid!(
|
32
|
+
"queries #{queries.join(", ")} must use the template variables #{variables.join(", ")}\n" \
|
33
|
+
"If that is not possible, add `validate: -> { false } # query foo in bar does not have baz tag`"
|
34
|
+
)
|
31
35
|
end
|
32
36
|
|
33
37
|
def widget_queries(widget)
|
data/lib/kennel/version.rb
CHANGED
data/template/Readme.md
CHANGED
@@ -180,6 +180,15 @@ end
|
|
180
180
|
end
|
181
181
|
```
|
182
182
|
|
183
|
+
### Updating existing resources with id
|
184
|
+
|
185
|
+
Setting `id` makes kennel take over a manually created datadog resource.
|
186
|
+
When manually creating to import, it is best to remove the `id` and delete the manually created resource.
|
187
|
+
|
188
|
+
When an `id` is set and the original resource is deleted, kennel will fail to update,
|
189
|
+
removing the `id` will cause kennel to create a new resource in datadog.
|
190
|
+
|
191
|
+
|
183
192
|
### Skipping validations
|
184
193
|
|
185
194
|
Some validations might be too strict for your usecase or just wrong, please [open an issue](https://github.com/grosser/kennel/issues) and
|
@@ -192,6 +201,7 @@ To link to existing monitors via their kennel_id `projects kennel_id` + `:` + `m
|
|
192
201
|
- Screens `uptime` widgets can use `monitor: {id: "foo:bar"}`
|
193
202
|
- Screens `alert_graph` widgets can use `alert_id: "foo:bar"`
|
194
203
|
- Monitors `composite` can use `query: -> { "%{foo:bar} || %{foo:baz}" }`
|
204
|
+
- Slos can use `monitor_ids: -> ["foo:bar"]`
|
195
205
|
|
196
206
|
### Debugging changes locally
|
197
207
|
|
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.78.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|