kennel 1.75.0 → 1.76.3

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6a61329e4c2b2ccec0021103dbca60ec7fb9658e3a45a0c4212a08e63ea1395
4
- data.tar.gz: 50af562a677393894101f495b150be434f7af67851e774109aa6b4605bedffab
3
+ metadata.gz: 17d17b2d23505b0d282fcab382a0bb43f452a132826c35a9fead4544631457db
4
+ data.tar.gz: d27f3363aafacb7885f833cf0c5d0d925d0b15f22a4d4aced5ff41377375b333
5
5
  SHA512:
6
- metadata.gz: c884d5d811aa4ed5df99e90382d2311391035570185149bae41f0ac0c080df6132877c4dcd9ffbba88a83e829203557353b405ed71b373e997337223192ed5b4
7
- data.tar.gz: 4e453ebad3dae75cd38f1901ab6ea50d22f886d2b3004ff3d25c3ab64881f852d7592b73a4efd0eabe244179ee39570f0028a62f3a1aa1bb0c47765c131fb097
6
+ metadata.gz: f5558fd02af6b9662955686724c4c406e23393de685ca5db815f02470439d1ece2f446400b154fdd700ac7d71507500022f4b0c1527e9f0b8769fcf99edfe699
7
+ data.tar.gz: 3969b3ae9a00f29bc9882ba4395b019d70e3562cbc2b2c6beca72a65352167d47c80fab7b560183a62c312f24f2ec7b147cf30385877b63044e137d26b7e65a3
data/Readme.md CHANGED
@@ -205,7 +205,7 @@ 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"`
@@ -215,7 +215,7 @@ To link to existing monitors via their kennel_id
215
215
 
216
216
  - rebase on updated `master` to not undo other changes
217
217
  - 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
218
+ - 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
219
 
220
220
  ### Reuse
221
221
 
@@ -257,7 +257,8 @@ Run `rake kennel:alerts TAG=service:my-service` to see all un-muted alerts for a
257
257
 
258
258
  ### Grepping through all of datadog
259
259
 
260
- `TYPE=monitor rake kennel:dump`
260
+ `rake kennel:dump`
261
+ focus on a single type: `TYPE=monitors`
261
262
 
262
263
  ### Find all monitors with No-Data
263
264
 
@@ -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)
@@ -42,10 +42,15 @@ module Kennel
42
42
 
43
43
  case resource
44
44
  when "monitor"
45
- # flatten monitor options so they are all on the base
45
+ # flatten monitor options so they are all on the base which is how Monitor builds them
46
46
  data.merge!(data.delete(:options))
47
47
  data.merge!(data.delete(:thresholds) || {})
48
- [:notify_no_data, :notify_audit].each { |k| data.delete(k) if data[k] } # monitor uses true by default
48
+
49
+ # clean up values that are the default
50
+ data.delete(:notify_no_data) if data[:notify_no_data] # Monitor uses true by default
51
+ data.delete(:notify_audit) unless data[:notify_audit] # Monitor uses false by default
52
+
53
+ # keep all values that are settable
49
54
  data = data.slice(*model.instance_methods)
50
55
 
51
56
  # make query use critical method if it matches
@@ -61,6 +66,8 @@ module Kennel
61
66
  widgets&.each { |widget| dry_up_query!(widget) }
62
67
  end
63
68
 
69
+ data.delete(:tags) if data[:tags] == [] # do not create super + [] call
70
+
64
71
  # simplify template_variables to array of string when possible
65
72
  if vars = data[:template_variables]
66
73
  vars.map! { |v| v[:default] == "*" && v[:prefix] == v[:name] ? v[:name] : v }
@@ -18,14 +18,16 @@ module Kennel
18
18
  new_host_delay: 300,
19
19
  timeout_h: 0,
20
20
  renotify_interval: 0,
21
- no_data_timeframe: nil # this works out ok since if notify_no_data is on, it would never be nil
21
+ notify_audit: false,
22
+ no_data_timeframe: nil, # this works out ok since if notify_no_data is on, it would never be nil
23
+ groupby_simple_monitor: false
22
24
  }.freeze
23
25
  DEFAULT_ESCALATION_MESSAGE = ["", nil].freeze
24
26
 
25
27
  settings(
26
28
  :query, :name, :message, :escalation_message, :critical, :type, :renotify_interval, :warning, :timeout_h, :evaluation_delay,
27
29
  :ok, :no_data_timeframe, :notify_no_data, :notify_audit, :tags, :critical_recovery, :warning_recovery, :require_full_window,
28
- :threshold_windows, :new_host_delay, :groupby_simple_monitor
30
+ :threshold_windows, :new_host_delay
29
31
  )
30
32
 
31
33
  defaults(
@@ -35,17 +37,16 @@ module Kennel
35
37
  warning: -> { nil },
36
38
  ok: -> { nil },
37
39
  id: -> { nil },
38
- notify_no_data: -> { true },
40
+ notify_no_data: -> { true }, # datadog sets this to false by default, but true is the safer
39
41
  no_data_timeframe: -> { 60 },
40
- notify_audit: -> { true },
42
+ notify_audit: -> { MONITOR_OPTION_DEFAULTS.fetch(:notify_audit) },
41
43
  new_host_delay: -> { MONITOR_OPTION_DEFAULTS.fetch(:new_host_delay) },
42
44
  tags: -> { @project.tags },
43
45
  timeout_h: -> { MONITOR_OPTION_DEFAULTS.fetch(:timeout_h) },
44
46
  evaluation_delay: -> { MONITOR_OPTION_DEFAULTS.fetch(:evaluation_delay) },
45
47
  critical_recovery: -> { nil },
46
48
  warning_recovery: -> { nil },
47
- threshold_windows: -> { nil },
48
- groupby_simple_monitor: -> { nil }
49
+ threshold_windows: -> { nil }
49
50
  )
50
51
 
51
52
  def as_json
@@ -95,11 +96,6 @@ module Kennel
95
96
  end
96
97
  end
97
98
 
98
- # option randomly pops up and cannot be removed
99
- unless (group = groupby_simple_monitor).nil?
100
- options[:groupby_simple_monitor] = group
101
- end
102
-
103
99
  if windows = threshold_windows
104
100
  options[:threshold_windows] = windows
105
101
  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
@@ -124,10 +124,18 @@ namespace :kennel do
124
124
  Kennel.out.puts Kennel::Importer.new(Kennel.send(:api)).import(resource, id)
125
125
  end
126
126
 
127
- desc "Dump ALL of datadog config as raw json ... useful for grep/search TYPE=slo|monitor|dashboard"
127
+ desc "Dump ALL of datadog config as raw json ... useful for grep/search [TYPE=slo|monitor|dashboard]"
128
128
  task dump: :environment do
129
- Kennel.send(:api).list(ENV.fetch("TYPE")).each do |r|
130
- Kennel.out.puts JSON.pretty_generate(r)
129
+ resources =
130
+ if type = ENV["TYPE"]
131
+ [type]
132
+ else
133
+ Kennel::Models::Record.subclasses.map(&:api_resource)
134
+ end
135
+ resources.each do |resource|
136
+ Kennel.send(:api).list(resource).each do |r|
137
+ Kennel.out.puts JSON.pretty_generate(r)
138
+ end
131
139
  end
132
140
  end
133
141
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.75.0"
3
+ VERSION = "1.76.3"
4
4
  end
@@ -187,7 +187,7 @@ 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"`
@@ -197,7 +197,7 @@ To link to existing monitors via their kennel_id
197
197
 
198
198
  - rebase on updated `master` to not undo other changes
199
199
  - 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
200
+ - 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
201
 
202
202
  ### Reuse
203
203
 
@@ -239,7 +239,8 @@ Run `rake kennel:alerts TAG=service:my-service` to see all un-muted alerts for a
239
239
 
240
240
  ### Grepping through all of datadog
241
241
 
242
- `TYPE=monitor rake kennel:dump`
242
+ `rake kennel:dump`
243
+ focus on a single type: `TYPE=monitors`
243
244
 
244
245
  ### Find all monitors with No-Data
245
246
 
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.75.0
4
+ version: 1.76.3
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-07-22 00:00:00.000000000 Z
11
+ date: 2020-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday