kennel 2.14.0 → 2.15.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: d289ac0af8158766eeced52cda258b67071189f889e6fa82d63cafe0b4cc7655
4
- data.tar.gz: 5a231e9da146ca9e008a8b507e2cbd4e11913c6f53d19fbd64af5c93b5b1a0aa
3
+ metadata.gz: f5e56bdcd6a89e07d259e9babdb5a25dd1d2e6b28fad74b4eccaa35348a4ade5
4
+ data.tar.gz: b1ace19a2a6b768a73c941d70d930ba8d4b07111618af83547f58c38133f080b
5
5
  SHA512:
6
- metadata.gz: a476cf37c12872c6cd4f1eeed55751840ffd5c6206dec0279d281f7862a47bd8e614fa14eefc0ffc32095a15f2d26d4a75b2298b60cc107bf09e1994562f0f15
7
- data.tar.gz: 29dfd3a9b22848badfb52da141620fde5fc89224974cade1e0cdda957a69d9b82798e4a6a03e95339f1cf907e8c036939fa1b5289cf9b8292b83e9e73e68e03a
6
+ metadata.gz: b311d407973c9773e4070d98870f02292cbc165dd94d91adb1f9b12df1998defd13ea38d1d490941b6297ed5d0a52fbc3825619184b576cb242771678b805f0e
7
+ data.tar.gz: 77ae75c61c8a38892e91b341a8d98fc1ee6115a8040d42ddf2618c0e7ba90fac596a24dc2b5dcc5c535fb5510b8d92b6a08f90c95a0e9fc62b6407da50dbc4de
data/Readme.md CHANGED
@@ -206,6 +206,7 @@ end
206
206
  class MyProject < Kennel::Models::Project
207
207
  defaults(
208
208
  team: -> { Teams::MyTeam.new }, # use existing team or create new one in teams/
209
+ # kennel_id: -> { "my_project" } # Custom kennel_id (default is snake_cased class name)
209
210
  parts: -> {
210
211
  [
211
212
  Kennel::Models::Monitor.new(
@@ -249,6 +250,7 @@ Remove the code that created the resource. The next update will delete it (see a
249
250
  - go to [datadog dashboard UI](https://app.datadoghq.com/dashboard/lists) and click on _New Dashboard_ to find a dashboard
250
251
  - run `URL='https://app.datadoghq.com/dashboard/bet-foo-bar' bundle exec rake kennel:import` and copy the output
251
252
  - find or create a project in `projects/`
253
+ - tags: only `team:` tags are submitted to datadog since nothing else is supported
252
254
  - add a dashboard to `parts: [` list, for example:
253
255
  ```Ruby
254
256
  class MyProject < Kennel::Models::Project
@@ -264,8 +266,9 @@ Remove the code that created the resource. The next update will delete it (see a
264
266
  template_variables: -> { ["environment"] }, # see https://docs.datadoghq.com/api/?lang=ruby#timeboards
265
267
  kennel_id: -> { "overview-dashboard" }, # make up a unique name
266
268
  layout_type: -> { "ordered" },
269
+ widgets: -> { "... raw widget definitions, most flexible ..." },
267
270
  definitions: -> {
268
- [ # An array or arrays, each one is a graph in the dashboard, alternatively a hash for finer control
271
+ [ # each element is a graph in the dashboard, alternatively a hash for complete control just like in `widgets`
269
272
  [
270
273
  # title, viz, type, query, edit an existing graph and see the json definition
271
274
  "Graph name", "timeseries", "area", "sum:mystats.foobar{$environment}"
@@ -274,7 +277,7 @@ Remove the code that created the resource. The next update will delete it (see a
274
277
  # queries can be an Array as well, this will generate multiple requests
275
278
  # for a single graph
276
279
  "Graph name", "timeseries", "area", ["sum:mystats.foobar{$environment}", "sum:mystats.success{$environment}"],
277
- # add events too ...
280
+ # add events too ... (also supports `:markers` and `:precision`)
278
281
  events: [{q: "tags:foobar,deploy", tags_execution: "and"}]
279
282
  ]
280
283
  ]
@@ -286,6 +289,55 @@ Remove the code that created the resource. The next update will delete it (see a
286
289
  end
287
290
  ```
288
291
 
292
+ ### Adding a new synthetic test
293
+ - go to [datadog synthetic tests UI](https://app.datadoghq.com/synthetics/tests) and click on _New_ to create a test
294
+ - see below
295
+
296
+ ### Updating an existing synthetic test
297
+ - go to [datadog synthetic tests UI](https://app.datadoghq.com/synthetics/tests) to find a test
298
+ - run `URL='https://app.datadoghq.com/synthetics/details/abc-def-ghi' bundle exec rake kennel:import` and copy the output
299
+ - find or create a project in `projects/`
300
+ - add a synthetic test to `parts: [` list, for example:
301
+ ```Ruby
302
+ class MyProject < Kennel::Models::Project
303
+ defaults(
304
+ team: -> { Teams::MyTeam.new },
305
+ parts: -> {
306
+ [
307
+ Kennel::Models::SyntheticTest.new(
308
+ self,
309
+ id: -> { "abc-def-ghi" }, # id from datadog url, not needed when creating a new test
310
+ kennel_id: -> { "my-api-test" },
311
+ name: -> { "My API Test" },
312
+ type: -> { "api" },
313
+ subtype: -> { "http" },
314
+ locations: -> { :all }, # use all locations, or specify: ["aws:us-east-1", "aws:eu-west-1"]
315
+ message: -> {
316
+ <<~TEXT
317
+ API check failed!
318
+ #{super()}
319
+ TEXT
320
+ },
321
+ options: -> {
322
+ {
323
+ tick_every: 60,
324
+ min_failure_duration: 0,
325
+ min_location_failed: 1
326
+ }
327
+ },
328
+ config: -> {
329
+ {
330
+ assertions: [{ type: "statusCode", operator: "is", target: 200 }],
331
+ request: { method: "GET", url: "https://example.com/health" }
332
+ }
333
+ }
334
+ )
335
+ ]
336
+ }
337
+ )
338
+ end
339
+ ```
340
+
289
341
  ### Updating existing resources with id
290
342
  Setting `id` makes kennel take over a manually created datadog resource.
291
343
  When manually creating to import, it is best to remove the `id` and delete the manually created resource.
@@ -327,10 +379,11 @@ module ProjectA
327
379
  - Use `TRACKING_ID=<project-kennel_id>:<resource-kennel_id>` for single resource:
328
380
 
329
381
  Use the project kennel_id and the resources kennel_id, for example `class ProjectA` and `FooAlert` would give `project_a:foo_alert`.
382
+ Alternatively use the path of the generated file `TRACKING_ID=generated/project_a/foo_alert.json`
330
383
 
331
384
  ### Skipping validations
332
385
  Some validations might be too strict for your usecase or just wrong, please [open an issue](https://github.com/grosser/kennel/issues) and
333
- to unblock use the `validate: -> { false }` option.
386
+ to unblock use `ignored_errors: [:name_of_the_error]`.
334
387
 
335
388
  ### Linking resources with kennel_id
336
389
  Link resources with their kennel_id in the format `project kennel_id` + `:` + `resource kennel_id`,
@@ -339,7 +392,7 @@ so they can be created in a single update and can be re-created if any of them i
339
392
 
340
393
  |Resource|Type|Syntax|
341
394
  |---|---|---|
342
- |Dashboard|uptime|`monitor: {id: "foo:bar"}`|
395
+ |Dashboard|uptime|`monitor_ids: ["foo:bar", "foo:baz"]`|
343
396
  |Dashboard|alert_graph|`alert_id: "foo:bar"`|
344
397
  |Dashboard|slo|`slo_id: "foo:bar"`|
345
398
  |Dashboard|timeseries|`queries: [{ data_source: "slo", slo_id: "foo:bar" }]`|
@@ -388,6 +441,9 @@ Run `rake kennel:alerts TAG=service:my-service` to see all un-muted alerts for a
388
441
  ### Validating mentions work
389
442
  `rake kennel:validate_mentions` should run as part of CI
390
443
 
444
+ Use `KNOWN=foo@bar.com,baz@bar.com` to exempt mentions that are not returned by the API.
445
+ Use `KNOWN_RANDOM=@sns-foo,@sns-bar` to ignore for example SNS handles that are randomly invalid in the API.
446
+
391
447
  ### Grepping through all of datadog
392
448
  ```Bash
393
449
  rake kennel:dump > tmp/dump
@@ -405,6 +461,9 @@ https://foo.datadog.com/monitor/123
405
461
  ### Find all monitors with No-Data
406
462
  `rake kennel:nodata TAG=team:foo`
407
463
 
464
+ - `FORMAT=json` to output as JSON with tracking IDs
465
+ - `THRESHOLD_DAYS=N` to filter to monitors with N+ days in no-data
466
+
408
467
  ### Finding the tracking id of a resource
409
468
 
410
469
  When trying to link resources together, this avoids having to go through datadog UI.
@@ -421,6 +480,14 @@ rake kennel:tracking_id ID=123 RESOURCE=monitor
421
480
  - Setting `FORCE_GET_CACHE=true` will cache all get requests, which makes benchmarking improvements more reliable.
422
481
  - Setting `STORE=false` will make `rake plan` not update the files on disk and save a bit of time
423
482
 
483
+ ### Other Environment Variables
484
+ | Variable | Description | Default |
485
+ |----------|-------------|---------|
486
+ | `KENNEL_MARKER_TEXT` | Custom marker text to namespace multiple Kennel instances in the same Datadog account. Each instance will only manage resources with its marker. | `Managed by kennel` |
487
+ | `KENNEL_API_CACHE_FILE` | Path to the API cache file for dashboard details. | `tmp/cache/details` |
488
+ | `KENNEL_NO_GENERATE` | When set, skip generating files during `plan` or `update_datadog`. Useful when generated files are already up to date. | - |
489
+ | `NO_IGNORED_ERRORS` | When set, show all validation errors including ones suppressed via `ignored_errors`. | - |
490
+
424
491
  ### Integration testing
425
492
  ```Bash
426
493
  rake play
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
3
  module Models
4
- class Team < Base
5
- settings :mention, :tags, :renotify_interval, :kennel_id
4
+ class Team
5
+ include SettingsAsMethods
6
+
7
+ settings :mention, :tags, :renotify_interval
6
8
  defaults(
7
- tags: -> { ["team:#{kennel_id.sub(/^teams_/, "").tr("_", "-")}"] },
9
+ tags: -> { ["team:#{StringUtils.snake_case(self.class.name).sub(/^teams_/, "").tr("_", "-")}"] },
8
10
  renotify_interval: -> { 0 }
9
11
  )
10
12
  end
data/lib/kennel/tasks.rb CHANGED
@@ -25,6 +25,7 @@ module Kennel
25
25
  source = ".env"
26
26
 
27
27
  # warn when users have things like DATADOG_TOKEN already set and it will not be loaded from .env
28
+ # (KENNEL_SILENCE_UPDATED_ENV is intentionally not documented - users see it when needed)
28
29
  unless ENV["KENNEL_SILENCE_UPDATED_ENV"]
29
30
  updated = Dotenv.parse(source).select { |k, v| ENV[k] && ENV[k] != v }
30
31
  warn "Environment variables #{updated.keys.join(", ")} need to be unset to be sourced from #{source}" if updated.any?
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "2.14.0"
3
+ VERSION = "2.15.0"
4
4
  end
data/template/Readme.md CHANGED
@@ -188,6 +188,7 @@ end
188
188
  class MyProject < Kennel::Models::Project
189
189
  defaults(
190
190
  team: -> { Teams::MyTeam.new }, # use existing team or create new one in teams/
191
+ # kennel_id: -> { "my_project" } # Custom kennel_id (default is snake_cased class name)
191
192
  parts: -> {
192
193
  [
193
194
  Kennel::Models::Monitor.new(
@@ -231,6 +232,7 @@ Remove the code that created the resource. The next update will delete it (see a
231
232
  - go to [datadog dashboard UI](https://app.datadoghq.com/dashboard/lists) and click on _New Dashboard_ to find a dashboard
232
233
  - run `URL='https://app.datadoghq.com/dashboard/bet-foo-bar' bundle exec rake kennel:import` and copy the output
233
234
  - find or create a project in `projects/`
235
+ - tags: only `team:` tags are submitted to datadog since nothing else is supported
234
236
  - add a dashboard to `parts: [` list, for example:
235
237
  ```Ruby
236
238
  class MyProject < Kennel::Models::Project
@@ -246,8 +248,9 @@ Remove the code that created the resource. The next update will delete it (see a
246
248
  template_variables: -> { ["environment"] }, # see https://docs.datadoghq.com/api/?lang=ruby#timeboards
247
249
  kennel_id: -> { "overview-dashboard" }, # make up a unique name
248
250
  layout_type: -> { "ordered" },
251
+ widgets: -> { "... raw widget definitions, most flexible ..." },
249
252
  definitions: -> {
250
- [ # An array or arrays, each one is a graph in the dashboard, alternatively a hash for finer control
253
+ [ # each element is a graph in the dashboard, alternatively a hash for complete control just like in `widgets`
251
254
  [
252
255
  # title, viz, type, query, edit an existing graph and see the json definition
253
256
  "Graph name", "timeseries", "area", "sum:mystats.foobar{$environment}"
@@ -256,7 +259,7 @@ Remove the code that created the resource. The next update will delete it (see a
256
259
  # queries can be an Array as well, this will generate multiple requests
257
260
  # for a single graph
258
261
  "Graph name", "timeseries", "area", ["sum:mystats.foobar{$environment}", "sum:mystats.success{$environment}"],
259
- # add events too ...
262
+ # add events too ... (also supports `:markers` and `:precision`)
260
263
  events: [{q: "tags:foobar,deploy", tags_execution: "and"}]
261
264
  ]
262
265
  ]
@@ -268,6 +271,55 @@ Remove the code that created the resource. The next update will delete it (see a
268
271
  end
269
272
  ```
270
273
 
274
+ ### Adding a new synthetic test
275
+ - go to [datadog synthetic tests UI](https://app.datadoghq.com/synthetics/tests) and click on _New_ to create a test
276
+ - see below
277
+
278
+ ### Updating an existing synthetic test
279
+ - go to [datadog synthetic tests UI](https://app.datadoghq.com/synthetics/tests) to find a test
280
+ - run `URL='https://app.datadoghq.com/synthetics/details/abc-def-ghi' bundle exec rake kennel:import` and copy the output
281
+ - find or create a project in `projects/`
282
+ - add a synthetic test to `parts: [` list, for example:
283
+ ```Ruby
284
+ class MyProject < Kennel::Models::Project
285
+ defaults(
286
+ team: -> { Teams::MyTeam.new },
287
+ parts: -> {
288
+ [
289
+ Kennel::Models::SyntheticTest.new(
290
+ self,
291
+ id: -> { "abc-def-ghi" }, # id from datadog url, not needed when creating a new test
292
+ kennel_id: -> { "my-api-test" },
293
+ name: -> { "My API Test" },
294
+ type: -> { "api" },
295
+ subtype: -> { "http" },
296
+ locations: -> { :all }, # use all locations, or specify: ["aws:us-east-1", "aws:eu-west-1"]
297
+ message: -> {
298
+ <<~TEXT
299
+ API check failed!
300
+ #{super()}
301
+ TEXT
302
+ },
303
+ options: -> {
304
+ {
305
+ tick_every: 60,
306
+ min_failure_duration: 0,
307
+ min_location_failed: 1
308
+ }
309
+ },
310
+ config: -> {
311
+ {
312
+ assertions: [{ type: "statusCode", operator: "is", target: 200 }],
313
+ request: { method: "GET", url: "https://example.com/health" }
314
+ }
315
+ }
316
+ )
317
+ ]
318
+ }
319
+ )
320
+ end
321
+ ```
322
+
271
323
  ### Updating existing resources with id
272
324
  Setting `id` makes kennel take over a manually created datadog resource.
273
325
  When manually creating to import, it is best to remove the `id` and delete the manually created resource.
@@ -309,10 +361,11 @@ module ProjectA
309
361
  - Use `TRACKING_ID=<project-kennel_id>:<resource-kennel_id>` for single resource:
310
362
 
311
363
  Use the project kennel_id and the resources kennel_id, for example `class ProjectA` and `FooAlert` would give `project_a:foo_alert`.
364
+ Alternatively use the path of the generated file `TRACKING_ID=generated/project_a/foo_alert.json`
312
365
 
313
366
  ### Skipping validations
314
367
  Some validations might be too strict for your usecase or just wrong, please [open an issue](https://github.com/grosser/kennel/issues) and
315
- to unblock use the `validate: -> { false }` option.
368
+ to unblock use `ignored_errors: [:name_of_the_error]`.
316
369
 
317
370
  ### Linking resources with kennel_id
318
371
  Link resources with their kennel_id in the format `project kennel_id` + `:` + `resource kennel_id`,
@@ -321,7 +374,7 @@ so they can be created in a single update and can be re-created if any of them i
321
374
 
322
375
  |Resource|Type|Syntax|
323
376
  |---|---|---|
324
- |Dashboard|uptime|`monitor: {id: "foo:bar"}`|
377
+ |Dashboard|uptime|`monitor_ids: ["foo:bar", "foo:baz"]`|
325
378
  |Dashboard|alert_graph|`alert_id: "foo:bar"`|
326
379
  |Dashboard|slo|`slo_id: "foo:bar"`|
327
380
  |Dashboard|timeseries|`queries: [{ data_source: "slo", slo_id: "foo:bar" }]`|
@@ -370,6 +423,9 @@ Run `rake kennel:alerts TAG=service:my-service` to see all un-muted alerts for a
370
423
  ### Validating mentions work
371
424
  `rake kennel:validate_mentions` should run as part of CI
372
425
 
426
+ Use `KNOWN=foo@bar.com,baz@bar.com` to exempt mentions that are not returned by the API.
427
+ Use `KNOWN_RANDOM=@sns-foo,@sns-bar` to ignore for example SNS handles that are randomly invalid in the API.
428
+
373
429
  ### Grepping through all of datadog
374
430
  ```Bash
375
431
  rake kennel:dump > tmp/dump
@@ -387,6 +443,9 @@ https://foo.datadog.com/monitor/123
387
443
  ### Find all monitors with No-Data
388
444
  `rake kennel:nodata TAG=team:foo`
389
445
 
446
+ - `FORMAT=json` to output as JSON with tracking IDs
447
+ - `THRESHOLD_DAYS=N` to filter to monitors with N+ days in no-data
448
+
390
449
  ### Finding the tracking id of a resource
391
450
 
392
451
  When trying to link resources together, this avoids having to go through datadog UI.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser