kennel 1.76.1 → 1.78.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +11 -1
- data/lib/kennel/api.rb +4 -1
- data/lib/kennel/models/monitor.rb +11 -7
- data/lib/kennel/models/slo.rb +2 -1
- data/lib/kennel/syncer.rb +4 -3
- data/lib/kennel/version.rb +1 -1
- data/template/Readme.md +11 -1
- 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: d12735939d42da2f660773d9ca734a279fdc5c29b6619f6722b163f07f299236
|
4
|
+
data.tar.gz: 14f40ae5314abc2ff5b58672ad096a9d1898b793c1dee490a45d9deefc67e513
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5340adfc8b564f648caa8f656b8b10fe9cd48177a6b15e21944adac24209344aeb81aa0bc5190e7a5997e8ebc0dc49af0304daf947abf99112dc8d56f6a9485
|
7
|
+
data.tar.gz: 368fb6dffbc42be889f8692b876e867818cde5eefd04b982151efc7d9dc74a378a046f12a7764f448df5818ebca950e55f22e36d45822c68ed3e8a3442850162
|
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,12 +219,13 @@ 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
|
|
216
226
|
- rebase on updated `master` to not undo other changes
|
217
227
|
- figure out project name by converting the class name to snake-case
|
218
|
-
- run `PROJECT=foo bundle exec rake kennel:update_datadog` to test changes for a single project
|
228
|
+
- run `PROJECT=foo bundle exec rake kennel:update_datadog` to test changes for a single project (monitors: remove mentions while debugging to avoid alert spam)
|
219
229
|
|
220
230
|
### Reuse
|
221
231
|
|
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,17 @@ 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! "#{match} used with #{group}, but can only be used with #{allowed.join(", ")}. Add more groupings or fix the #{match}"
|
213
|
+
end
|
210
214
|
end
|
211
215
|
end
|
212
216
|
end
|
data/lib/kennel/models/slo.rb
CHANGED
@@ -63,10 +63,11 @@ module Kennel
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def self.parse_url(url)
|
66
|
-
url[/\/slo
|
66
|
+
url[/\/slo\?.*slo_id=([a-z\d]+)/, 1]
|
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
|
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,12 +201,13 @@ 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
|
|
198
208
|
- rebase on updated `master` to not undo other changes
|
199
209
|
- figure out project name by converting the class name to snake-case
|
200
|
-
- run `PROJECT=foo bundle exec rake kennel:update_datadog` to test changes for a single project
|
210
|
+
- run `PROJECT=foo bundle exec rake kennel:update_datadog` to test changes for a single project (monitors: remove mentions while debugging to avoid alert spam)
|
201
211
|
|
202
212
|
### Reuse
|
203
213
|
|
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.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: 2020-
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|