kennel 1.96.1 → 1.98.1

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: aca7576bcde423ec1f4e559d88f13ee64ed5efb116a212f49e67ac6b792ddb16
4
- data.tar.gz: a6b60f7d6a73ca82d2478f565435e0ebb95a79f7d3bd5bcebfd6712a3e9c8cfb
3
+ metadata.gz: 4d0b70ee90aae5a476b1e9a324e02346856e9d76881082d46a2b219efcfe2267
4
+ data.tar.gz: 86bc3f4777ec06a9b8c171e93ea95b50e9117a74283e3e6c1785d81e87889a4d
5
5
  SHA512:
6
- metadata.gz: 1767ebe1e61ea9a314b99f14a2cd15a31dc09419dafa2a9100244c83acfc40cd9eba0ccf1e9ad6c4cf9c3026cd1493e6b62cdc6a867b18720ed517908e702768
7
- data.tar.gz: 382486fbfb3c52346262ad43c63ed21164676189a880d405914de54539907a0a193960f173daa9aa16f41d847959b140a9c60cee886f85d63473d599bd00b807
6
+ metadata.gz: d0c6f38a11af7b0876a5637648fe16168aa4c5f6a16bba06f51322c240b02d520bd3abf566bf04b547df7431453d500f97be06b3a03da850ca5395b6ccf04bed
7
+ data.tar.gz: 45a77a1b2995f12da465a5b2ed64c6f21c93dba68b154367cf06c2a88202b648e223f0f1f80da7052e536b64f66a3cdc72a607fabfb913db3c7657f9e4000051
data/Readme.md CHANGED
@@ -16,7 +16,6 @@ Manage Datadog Monitors / Dashboards / Slos as code
16
16
  ![](template/github/screen.png?raw=true)
17
17
 
18
18
  ### Example code
19
-
20
19
  ```Ruby
21
20
  # teams/foo.rb
22
21
  module Teams
@@ -52,9 +51,7 @@ end
52
51
  ```
53
52
 
54
53
  <!-- NOT IN template/Readme.md -->
55
-
56
54
  ## Installation
57
-
58
55
  - create a new private `kennel` repo for your organization (do not fork this repo)
59
56
  - use the template folder as starting point:
60
57
  ```Bash
@@ -70,14 +67,12 @@ end
70
67
  <!-- NOT IN -->
71
68
 
72
69
  ## Structure
73
-
74
70
  - `projects/` monitors/dashboards/etc scoped by project
75
71
  - `teams/` team definitions
76
72
  - `parts/` monitors/dashboards/etc that are used by multiple projects
77
73
  - `generated/` projects as json, to show current state and proposed changes in PRs
78
74
 
79
75
  ## Workflows
80
-
81
76
  <!-- ONLY IN template/Readme.md
82
77
  ### Setup
83
78
  - clone the repo
@@ -91,7 +86,6 @@ end
91
86
  -->
92
87
 
93
88
  ### Adding a team
94
-
95
89
  - `mention` is used for all team monitors via `super()`
96
90
  - `renotify_interval` is used for all team monitors (defaults to `0` / off)
97
91
  - `tags` is used for all team monitors/dashboards (defaults to `team:<team-name>`)
@@ -208,14 +202,30 @@ When manually creating to import, it is best to remove the `id` and delete the m
208
202
  When an `id` is set and the original resource is deleted, kennel will fail to update,
209
203
  removing the `id` will cause kennel to create a new resource in datadog.
210
204
 
205
+ ### Organizing large sub-projects / large organiations
206
+ Having many projects (and their sub-resources) can quickly get out of hand.
211
207
 
212
- ### Skipping validations
208
+ Use this class structure to keep things organized:
209
+ ```ruby
210
+ # projects/project_a/base.rb
211
+ module ProjectA
212
+ class Base < Kennel::Models::Project
213
+ defaults(
214
+ kennel_id: -> { "project_a" },
215
+ ...
216
+
217
+ # projects/project_a/monitors/foo_alert.rb
218
+ module ProjectA
219
+ module Monitors
220
+ class FooAlert < Kennel::Modesl::Monitor
221
+ ...
222
+ ```
213
223
 
224
+ ### Skipping validations
214
225
  Some validations might be too strict for your usecase or just wrong, please [open an issue](https://github.com/grosser/kennel/issues) and
215
226
  to unblock use the `validate: -> { false }` option.
216
227
 
217
228
  ### Linking resources with kennel_id
218
-
219
229
  Link resources with their kennel_id in the format `project kennel_id` + `:` + `resource kennel_id`,
220
230
  this should be used to create dependent resources like monitor + slos,
221
231
  so they can be created in a single update and can be re-created if any of them is deleted.
@@ -230,13 +240,11 @@ so they can be created in a single update and can be re-created if any of them i
230
240
  |Slo|monitor|`monitor_ids: -> ["foo:bar"]`|
231
241
 
232
242
  ### Debugging changes locally
233
-
234
243
  - rebase on updated `master` to not undo other changes
235
244
  - figure out project name by converting the class name to snake-case
236
245
  - 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)
237
246
 
238
247
  ### Reuse
239
-
240
248
  Add to `parts/<folder>`.
241
249
 
242
250
  ```Ruby
@@ -266,15 +274,12 @@ end
266
274
  ## Helpers
267
275
 
268
276
  ### Listing un-muted alerts
269
-
270
277
  Run `rake kennel:alerts TAG=service:my-service` to see all un-muted alerts for a given datadog monitor tag.
271
278
 
272
279
  ### Validating mentions work
273
-
274
280
  `rake kennel:validate_mentions` should run as part of CI
275
281
 
276
282
  ### Grepping through all of datadog
277
-
278
283
  ```Bash
279
284
  rake kennel:dump > tmp/dump
280
285
  cat tmp/dump | grep foo
@@ -289,7 +294,6 @@ https://foo.datadog.com/monitor/123
289
294
  ```
290
295
 
291
296
  ### Find all monitors with No-Data
292
-
293
297
  `rake kennel:nodata TAG=team:foo`
294
298
 
295
299
  <!-- NOT IN template/Readme.md -->
@@ -297,11 +301,9 @@ https://foo.datadog.com/monitor/123
297
301
  ## Development
298
302
 
299
303
  ### Benchmarking
300
-
301
304
  Setting `FORCE_GET_CACHE=true` will cache all get requests, which makes benchmarking improvements more reliable.
302
305
 
303
306
  ### Integration testing
304
-
305
307
  ```Bash
306
308
  rake play
307
309
  cd template
@@ -31,7 +31,7 @@ module Kennel
31
31
  settings(
32
32
  :query, :name, :message, :escalation_message, :critical, :type, :renotify_interval, :warning, :timeout_h, :evaluation_delay,
33
33
  :ok, :no_data_timeframe, :notify_no_data, :notify_audit, :tags, :critical_recovery, :warning_recovery, :require_full_window,
34
- :threshold_windows, :new_host_delay, :priority
34
+ :threshold_windows, :new_host_delay, :new_group_delay, :priority
35
35
  )
36
36
 
37
37
  defaults(
@@ -45,6 +45,7 @@ module Kennel
45
45
  no_data_timeframe: -> { 60 },
46
46
  notify_audit: -> { MONITOR_OPTION_DEFAULTS.fetch(:notify_audit) },
47
47
  new_host_delay: -> { MONITOR_OPTION_DEFAULTS.fetch(:new_host_delay) },
48
+ new_group_delay: -> { nil },
48
49
  tags: -> { @project.tags },
49
50
  timeout_h: -> { MONITOR_OPTION_DEFAULTS.fetch(:timeout_h) },
50
51
  evaluation_delay: -> { MONITOR_OPTION_DEFAULTS.fetch(:evaluation_delay) },
@@ -70,6 +71,7 @@ module Kennel
70
71
  notify_audit: notify_audit,
71
72
  require_full_window: require_full_window,
72
73
  new_host_delay: new_host_delay,
74
+ new_group_delay: new_group_delay,
73
75
  include_tags: true,
74
76
  escalation_message: Utils.presence(escalation_message.strip),
75
77
  evaluation_delay: evaluation_delay,
@@ -106,6 +108,9 @@ module Kennel
106
108
  options[:threshold_windows] = windows
107
109
  end
108
110
 
111
+ # Datadog requires only either new_group_delay or new_host_delay, never both
112
+ options.delete(options[:new_group_delay] ? :new_host_delay : :new_group_delay)
113
+
109
114
  validate_json(data) if validate
110
115
 
111
116
  @as_json = data
@@ -2,7 +2,7 @@
2
2
  module Kennel
3
3
  module Models
4
4
  class Project < Base
5
- settings :team, :parts, :tags, :mention
5
+ settings :team, :parts, :tags, :mention, :name, :kennel_id
6
6
  defaults(
7
7
  tags: -> { ["service:#{kennel_id}"] + team.tags },
8
8
  mention: -> { team.mention }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.96.1"
3
+ VERSION = "1.98.1"
4
4
  end
data/template/Readme.md CHANGED
@@ -16,7 +16,6 @@ Manage Datadog Monitors / Dashboards / Slos as code
16
16
  ![](github/screen.png?raw=true)
17
17
 
18
18
  ### Example code
19
-
20
19
  ```Ruby
21
20
  # teams/foo.rb
22
21
  module Teams
@@ -53,14 +52,12 @@ end
53
52
 
54
53
 
55
54
  ## Structure
56
-
57
55
  - `projects/` monitors/dashboards/etc scoped by project
58
56
  - `teams/` team definitions
59
57
  - `parts/` monitors/dashboards/etc that are used by multiple projects
60
58
  - `generated/` projects as json, to show current state and proposed changes in PRs
61
59
 
62
60
  ## Workflows
63
-
64
61
  ### Setup
65
62
  - clone the repo
66
63
  - `gem install bundler && bundle install`
@@ -72,7 +69,6 @@ end
72
69
  - verify it works by running `rake plan`, it might show some diff, but should not crash
73
70
 
74
71
  ### Adding a team
75
-
76
72
  - `mention` is used for all team monitors via `super()`
77
73
  - `renotify_interval` is used for all team monitors (defaults to `0` / off)
78
74
  - `tags` is used for all team monitors/dashboards (defaults to `team:<team-name>`)
@@ -189,14 +185,30 @@ When manually creating to import, it is best to remove the `id` and delete the m
189
185
  When an `id` is set and the original resource is deleted, kennel will fail to update,
190
186
  removing the `id` will cause kennel to create a new resource in datadog.
191
187
 
188
+ ### Organizing large sub-projects / large organiations
189
+ Having many projects (and their sub-resources) can quickly get out of hand.
192
190
 
193
- ### Skipping validations
191
+ Use this class structure to keep things organized:
192
+ ```ruby
193
+ # projects/project_a/base.rb
194
+ module ProjectA
195
+ class Base < Kennel::Models::Project
196
+ defaults(
197
+ kennel_id: -> { "project_a" },
198
+ ...
199
+
200
+ # projects/project_a/monitors/foo_alert.rb
201
+ module ProjectA
202
+ module Monitors
203
+ class FooAlert < Kennel::Modesl::Monitor
204
+ ...
205
+ ```
194
206
 
207
+ ### Skipping validations
195
208
  Some validations might be too strict for your usecase or just wrong, please [open an issue](https://github.com/grosser/kennel/issues) and
196
209
  to unblock use the `validate: -> { false }` option.
197
210
 
198
211
  ### Linking resources with kennel_id
199
-
200
212
  Link resources with their kennel_id in the format `project kennel_id` + `:` + `resource kennel_id`,
201
213
  this should be used to create dependent resources like monitor + slos,
202
214
  so they can be created in a single update and can be re-created if any of them is deleted.
@@ -211,13 +223,11 @@ so they can be created in a single update and can be re-created if any of them i
211
223
  |Slo|monitor|`monitor_ids: -> ["foo:bar"]`|
212
224
 
213
225
  ### Debugging changes locally
214
-
215
226
  - rebase on updated `master` to not undo other changes
216
227
  - figure out project name by converting the class name to snake-case
217
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)
218
229
 
219
230
  ### Reuse
220
-
221
231
  Add to `parts/<folder>`.
222
232
 
223
233
  ```Ruby
@@ -247,15 +257,12 @@ end
247
257
  ## Helpers
248
258
 
249
259
  ### Listing un-muted alerts
250
-
251
260
  Run `rake kennel:alerts TAG=service:my-service` to see all un-muted alerts for a given datadog monitor tag.
252
261
 
253
262
  ### Validating mentions work
254
-
255
263
  `rake kennel:validate_mentions` should run as part of CI
256
264
 
257
265
  ### Grepping through all of datadog
258
-
259
266
  ```Bash
260
267
  rake kennel:dump > tmp/dump
261
268
  cat tmp/dump | grep foo
@@ -270,6 +277,5 @@ https://foo.datadog.com/monitor/123
270
277
  ```
271
278
 
272
279
  ### Find all monitors with No-Data
273
-
274
280
  `rake kennel:nodata TAG=team:foo`
275
281
 
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.96.1
4
+ version: 1.98.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: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday