kennel 1.74.1 → 1.76.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +7 -6
- data/lib/kennel/github_reporter.rb +4 -2
- data/lib/kennel/importer.rb +9 -2
- data/lib/kennel/models/monitor.rb +7 -11
- data/lib/kennel/models/slo.rb +1 -1
- data/lib/kennel/tasks.rb +17 -8
- data/lib/kennel/version.rb +1 -1
- data/template/Readme.md +5 -4
- 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: f414fdeaa15b105fde4fa0cbcf70956246bcafafd31aa3d4a48dbed37e3a31ff
|
4
|
+
data.tar.gz: b29014f8c562d772429a09ede70ad92d7ad892f4359628c66e24535cd50e4232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb2504d598f41a5fb3f75431cadaf58749b4d8d381d8c87f89125c703c8122c916ceb3064e25332d2f8f0c8b9f0b69b28d76f1c71000d515e7e027e2df118da
|
7
|
+
data.tar.gz: 75f379f50a897704e3bb488960920ce2e11e79249d32ad77b851d05ed6ed5c886ce060869c1bad6474b383fdb4ebcb8c117b051bf1e88b9fa590d96cede73284
|
data/Readme.md
CHANGED
@@ -63,8 +63,8 @@ end
|
|
63
63
|
cd kennel && git add . && git commit -m 'initial'
|
64
64
|
```
|
65
65
|
- add a basic projects and teams so others can copy-paste to get started
|
66
|
-
- setup
|
67
|
-
- uncomment `.travis.yml` section for datadog updates on merge
|
66
|
+
- setup CI build for your repo (travis and Github Actions supported)
|
67
|
+
- uncomment `.travis.yml` section for datadog updates on merge (TODO: example setup for Github Actions)
|
68
68
|
- follow `Setup` in your repos Readme.md
|
69
69
|
<!-- NOT IN -->
|
70
70
|
|
@@ -150,7 +150,7 @@ end
|
|
150
150
|
- alternatively: `bundle exec rake generate` to only locally update the generated `json` files
|
151
151
|
- review changes then `git commit`
|
152
152
|
- make a PR ... get reviewed ... merge
|
153
|
-
- datadog is updated by
|
153
|
+
- datadog is updated by CI
|
154
154
|
|
155
155
|
### Adding a new dashboard
|
156
156
|
- go to [datadog dashboard UI](https://app.datadoghq.com/dashboard/lists) and click on _New Dashboard_ to create a dashboard
|
@@ -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
|
-
`
|
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
|
-
|
19
|
-
|
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)
|
data/lib/kennel/importer.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
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: -> {
|
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
|
data/lib/kennel/models/slo.rb
CHANGED
data/lib/kennel/tasks.rb
CHANGED
@@ -68,15 +68,16 @@ namespace :kennel do
|
|
68
68
|
Kennel.update
|
69
69
|
end
|
70
70
|
|
71
|
-
desc "update
|
72
|
-
task :
|
73
|
-
|
74
|
-
|
71
|
+
desc "update on push to the default branch, otherwise show plan"
|
72
|
+
task :ci do
|
73
|
+
branch = (ENV["TRAVIS_BRANCH"] || ENV["GITHUB_REF"]).to_s.sub(/^refs\/heads\//, "")
|
74
|
+
on_default_branch = (branch == (ENV["DEFAULT_BRANCH"] || "master"))
|
75
|
+
is_push = (ENV["TRAVIS_PULL_REQUEST"] == "false" || ENV["GITHUB_EVENT_NAME"] == "push")
|
75
76
|
task_name =
|
76
77
|
if on_default_branch && is_push
|
77
78
|
"kennel:update_datadog"
|
78
79
|
else
|
79
|
-
"kennel:plan" # show plan in
|
80
|
+
"kennel:plan" # show plan in CI logs
|
80
81
|
end
|
81
82
|
|
82
83
|
Rake::Task[task_name].invoke
|
@@ -123,10 +124,18 @@ namespace :kennel do
|
|
123
124
|
Kennel.out.puts Kennel::Importer.new(Kennel.send(:api)).import(resource, id)
|
124
125
|
end
|
125
126
|
|
126
|
-
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]"
|
127
128
|
task dump: :environment do
|
128
|
-
|
129
|
-
|
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
|
130
139
|
end
|
131
140
|
end
|
132
141
|
|
data/lib/kennel/version.rb
CHANGED
data/template/Readme.md
CHANGED
@@ -132,7 +132,7 @@ end
|
|
132
132
|
- alternatively: `bundle exec rake generate` to only locally update the generated `json` files
|
133
133
|
- review changes then `git commit`
|
134
134
|
- make a PR ... get reviewed ... merge
|
135
|
-
- datadog is updated by
|
135
|
+
- datadog is updated by CI
|
136
136
|
|
137
137
|
### Adding a new dashboard
|
138
138
|
- go to [datadog dashboard UI](https://app.datadoghq.com/dashboard/lists) and click on _New Dashboard_ to create a dashboard
|
@@ -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
|
-
`
|
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.
|
4
|
+
version: 1.76.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-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|