kennel 1.76.0 → 1.78.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a109923efbaef4c2beb6ccf136ea593a43c06b92e45add81d7f07fcbd594779e
4
- data.tar.gz: 44a1b83e6b2e708eb3f91d98c19e90aeb663f4a6cf0926f296faae2b2570064d
3
+ metadata.gz: 9d1a7ffddfc55955603d8ac9826ab2f46af2f223cb92f829ac1be0f2dc29af4c
4
+ data.tar.gz: fe2a7fa8bdf812bb7e4cf79a3e14ab8923225f8464ac352723ab18e54be9fc3f
5
5
  SHA512:
6
- metadata.gz: bfb64f23ff80eca8a8034a2bbb7c2cb08e867ec356879b85b487b093cea1109a5fca0da431355fdd597693a4da2b6a42231b99deb23398d562dfd74650448b64
7
- data.tar.gz: e3034cd7215d04fd2020e6d12e27c1831f8e4167c3befaf24cd6725c81e9caafc71c7b14a8813d55fdd8439ae7ec4a4efa09a58a9c2d1c4616d302c77ed87a20
6
+ metadata.gz: af3734bc932520ec215baa7cbf31f40553d50b48f0c61d80835a030cb728af8cb139c4e7296ad82792a54b699971a6892da227674b1b50f659bd787cbe743a0c
7
+ data.tar.gz: 9f01dd98d5467bf60cdfa2943925fa0edece4d74970ba2e17888b5dcce51f6f59a15cd70c6d6208e1e83c5ebd65339e7a2e7f5c52f490ece1cffce0ad170f8b3
data/Readme.md CHANGED
@@ -205,17 +205,18 @@ to unblock use the `validate: -> { false }` option.
205
205
 
206
206
  ### Linking with kennel_ids
207
207
 
208
- To link to existing monitors via their kennel_id
208
+ To link to existing monitors via their kennel_id `projects kennel_id` + `:` + `monitors kennel id`
209
209
 
210
210
  - Screens `uptime` widgets can use `monitor: {id: "foo:bar"}`
211
211
  - Screens `alert_graph` widgets can use `alert_id: "foo:bar"`
212
212
  - Monitors `composite` can use `query: -> { "%{foo:bar} || %{foo:baz}" }`
213
+ - Slos can use `monitor_ids: -> ["foo:bar"]`
213
214
 
214
215
  ### Debugging changes locally
215
216
 
216
217
  - rebase on updated `master` to not undo other changes
217
218
  - 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
219
+ - 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
220
 
220
221
  ### Reuse
221
222
 
@@ -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
@@ -15,8 +15,10 @@ module Kennel
15
15
  def initialize(token, git_sha)
16
16
  @token = token
17
17
  @git_sha = git_sha
18
- origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
19
- @repo_part = origin[%r{github\.com[:/](.+?)(\.git|$)}, 1] || raise("no origin found")
18
+ @repo_part = ENV["GITHUB_REPOSITORY"] || begin
19
+ origin = ENV["PROJECT_REPOSITORY"] || Utils.capture_sh("git remote -v").split("\n").first
20
+ origin[%r{github\.com[:/](\S+?)(\.git|$)}, 1] || raise("no origin found in #{origin}")
21
+ end
20
22
  end
21
23
 
22
24
  def report(&block)
@@ -192,7 +192,7 @@ module Kennel
192
192
  end
193
193
 
194
194
  if type == "query alert"
195
- # verify interval is valud
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*#is_match\s*"([a-zA-Z\d_.-]+).name"/).flatten.uniq
206
- allowed = data.fetch(:query)[/by\s*[({]([^})]+)[})]/, 1].to_s.gsub(/["']/, "").split(/\s*,\s*/)
207
- unsupported = used - allowed
208
- if unsupported.any?
209
- invalid! "is_match used with #{unsupported}, but metric is only grouped by #{allowed}"
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
@@ -63,10 +63,11 @@ module Kennel
63
63
  end
64
64
 
65
65
  def self.parse_url(url)
66
- url[/\/slo\?slo_id=([a-z\d]+)/, 1]
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
@@ -38,7 +38,7 @@ module Kennel
38
38
  end
39
39
 
40
40
  def update
41
- changed = (@create + @update).map { |_, e| e } unless @create.empty?
41
+ changed = (@create + @update).map { |_, e| e }
42
42
 
43
43
  @create.each do |_, e|
44
44
  e.resolve_linked_tracking_ids!({}, force: true)
@@ -188,7 +188,7 @@ module Kennel
188
188
  end
189
189
 
190
190
  # Do not add tracking-id when working with existing ids on a branch,
191
- # so resource do not get deleted fr:om merges to master.
191
+ # so resource do not get deleted from running an update on master (for example merge->CI).
192
192
  # Also make sure the diff still makes sense, by kicking out the now noop-update.
193
193
  #
194
194
  # Note: ideally we'd never add tracking in the first place, but at that point we do not know the diff yet
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.76.0"
3
+ VERSION = "1.78.0"
4
4
  end
@@ -187,17 +187,18 @@ to unblock use the `validate: -> { false }` option.
187
187
 
188
188
  ### Linking with kennel_ids
189
189
 
190
- To link to existing monitors via their kennel_id
190
+ To link to existing monitors via their kennel_id `projects kennel_id` + `:` + `monitors kennel id`
191
191
 
192
192
  - Screens `uptime` widgets can use `monitor: {id: "foo:bar"}`
193
193
  - Screens `alert_graph` widgets can use `alert_id: "foo:bar"`
194
194
  - Monitors `composite` can use `query: -> { "%{foo:bar} || %{foo:baz}" }`
195
+ - Slos can use `monitor_ids: -> ["foo:bar"]`
195
196
 
196
197
  ### Debugging changes locally
197
198
 
198
199
  - rebase on updated `master` to not undo other changes
199
200
  - 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
201
+ - 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
202
 
202
203
  ### Reuse
203
204
 
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.76.0
4
+ version: 1.78.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: 2020-08-23 00:00:00.000000000 Z
11
+ date: 2020-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday