kennel 1.61.2 → 1.62.1

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: dd27c1efc9afa4ba43482978f3be42ae2ff6301b1532ae3461c043d503fc82c3
4
- data.tar.gz: cc6209799a8b73dd0aca242e8f9a29a8693a2701c888ca3487f8dea0dfb9d100
3
+ metadata.gz: f5ad82b24cba6eef0e7733dac0b4c0f51e54fb728338112c8505ddf84284df23
4
+ data.tar.gz: c6bf110be71f0296d352797ed7f8ac364dfa18e580a632ef1ad21e427da65111
5
5
  SHA512:
6
- metadata.gz: 28398d5ef02978e71c877edd65a4eb6a462ff1886df46d0bfabac621d640eb67f876d73dacfd52ef2c906c8715de006a7fc9e60d6663f4323f28fcd948cf4f36
7
- data.tar.gz: 49581fac6bd3c3112f0d13cae7465580af642a78135f5b49c4e053d27bd66138b9e88b090912a96e943428903c7bcd8e07960c6beb2b406ecc795a69f4348775
6
+ metadata.gz: 85b2929f6e429c64be88d96dbbfb76f057fa56d1dea6eb81668e728b214ff4cd91a6345899199f95034c75414444519d6d7f585174687866f99c20481e547172
7
+ data.tar.gz: 55412cc487dffdf9de2e4f715fb3773690591753793fe2ea799677f853b3c42348e1fbc6ed13a8e7adc3d45d0fd3ac9141a825ef10d4a2066cdb58350e3632ff
data/Readme.md CHANGED
@@ -6,8 +6,7 @@ Keep datadog monitors/dashboards/etc in version control, avoid chaotic managemen
6
6
 
7
7
  - Documented, reusable, automated, and searchable configuration
8
8
  - Changes are PR reviewed and auditable
9
- - Good defaults like no-data / re-notify are preselected
10
- - Reliable cleanup with automated deletion
9
+ - Automated deletion when removed from code
11
10
 
12
11
  ![](template/github/screen.png?raw=true)
13
12
  <!-- NOT IN template/Readme.md -->
@@ -18,7 +17,7 @@ Keep datadog monitors/dashboards/etc in version control, avoid chaotic managemen
18
17
  ```Bash
19
18
  git clone git@github.com:your-org/kennel.git
20
19
  git clone git@github.com:grosser/kennel.git seed
21
- mv seed/teamplate/* kennel/
20
+ mv seed/template/* kennel/
22
21
  cd kennel && git add . && git commit -m 'initial'
23
22
  ```
24
23
  - add a basic projects and teams so others can copy-paste to get started
@@ -31,7 +30,7 @@ Keep datadog monitors/dashboards/etc in version control, avoid chaotic managemen
31
30
 
32
31
  - `projects/` monitors/dashboards/etc scoped by project
33
32
  - `teams/` team definitions
34
- - `parts/` monitors/dashes/etc that are used by multiple projects
33
+ - `parts/` monitors/dashboards/etc that are used by multiple projects
35
34
  - `generated/` projects as json, to show current state and proposed changes in PRs
36
35
 
37
36
  ## Workflows
@@ -125,22 +125,23 @@ module Kennel
125
125
  end
126
126
 
127
127
  def resolve_linked_tracking_ids(id_map)
128
- as_json[:widgets].each do |widget|
128
+ widgets = as_json[:widgets].flat_map { |w| [w, *w.dig(:definition, :widgets) || []] }
129
+ widgets.each do |widget|
129
130
  next unless definition = widget[:definition]
130
131
  case definition[:type]
131
132
  when "uptime"
132
133
  if ids = definition[:monitor_ids]
133
134
  definition[:monitor_ids] = ids.map do |id|
134
- tracking_id?(id) ? resolve_link(id, id_map) : id
135
+ tracking_id?(id) ? resolve_link(id, :monitor, id_map) : id
135
136
  end
136
137
  end
137
138
  when "alert_graph"
138
139
  if (id = definition[:alert_id]) && tracking_id?(id)
139
- definition[:alert_id] = resolve_link(id, id_map).to_s
140
+ definition[:alert_id] = resolve_link(id, :monitor, id_map).to_s
140
141
  end
141
142
  when "slo"
142
143
  if (id = definition[:slo_id]) && tracking_id?(id)
143
- definition[:slo_id] = resolve_link(id, id_map).to_s
144
+ definition[:slo_id] = resolve_link(id, :slo, id_map).to_s
144
145
  end
145
146
  end
146
147
  end
@@ -149,7 +150,7 @@ module Kennel
149
150
  private
150
151
 
151
152
  def tracking_id?(id)
152
- id.is_a?(String) && !id.match?(/\A\d+\z/)
153
+ id.is_a?(String) && id.include?(":")
153
154
  end
154
155
 
155
156
  # creates queries from metadata to avoid having to keep q and expression in sync
@@ -8,7 +8,7 @@ module Kennel
8
8
  QUERY_INTERVALS = ["1m", "5m", "10m", "15m", "30m", "1h", "2h", "4h", "1d"].freeze
9
9
  OPTIONAL_SERVICE_CHECK_THRESHOLDS = [:ok, :warning].freeze
10
10
  READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [
11
- :multi, :matching_downtimes, :overall_state_modified, :overall_state
11
+ :multi, :matching_downtimes, :overall_state_modified, :overall_state, :restricted_roles
12
12
  ]
13
13
 
14
14
  # defaults that datadog uses when options are not sent, so safe to leave out if our values match their defaults
@@ -35,7 +35,7 @@ module Kennel
35
35
  ok: -> { nil },
36
36
  id: -> { nil },
37
37
  notify_no_data: -> { true },
38
- no_data_timeframe: -> { notify_no_data ? 60 : nil },
38
+ no_data_timeframe: -> { 60 },
39
39
  notify_audit: -> { true },
40
40
  new_host_delay: -> { MONITOR_OPTION_DEFAULTS.fetch(:new_host_delay) },
41
41
  tags: -> { @project.tags },
@@ -57,7 +57,7 @@ module Kennel
57
57
  options: {
58
58
  timeout_h: timeout_h,
59
59
  notify_no_data: notify_no_data,
60
- no_data_timeframe: no_data_timeframe,
60
+ no_data_timeframe: notify_no_data ? no_data_timeframe : nil,
61
61
  notify_audit: notify_audit,
62
62
  require_full_window: require_full_window,
63
63
  new_host_delay: new_host_delay,
@@ -106,7 +106,7 @@ module Kennel
106
106
  if as_json[:type] == "composite"
107
107
  as_json[:query] = as_json[:query].gsub(/%\{(.*?)\}/) do
108
108
  # need force here since it validates the id exists
109
- resolve_link($1, id_map, force: true)
109
+ resolve_link($1, :monitor, id_map, force: true)
110
110
  end
111
111
  end
112
112
  end
@@ -54,19 +54,20 @@ module Kennel
54
54
 
55
55
  private
56
56
 
57
- def resolve_link(id, id_map, force: false)
57
+ def resolve_link(id, type, id_map, force: false)
58
58
  found = id_map[id]
59
59
  return found if found && found != :new
60
+ api_resource = self.class.api_resource
60
61
 
61
62
  if found == :new
62
63
  if force
63
- invalid! "Monitor #{id} will be created in the current run and can only be used after that"
64
+ invalid! "#{api_resource.capitalize} #{id} will be created in the current run and can only be used after that"
64
65
  else
65
- Kennel.err.puts "Monitor #{id} will be created in the current run, the next run will link it properly"
66
+ Kennel.err.puts "#{api_resource.capitalize} #{id} will be created in the current run, the next run will link it properly"
66
67
  Kennel::MISSING_ID
67
68
  end
68
69
  else
69
- invalid! "Unable to find monitor #{id} (does not exist and is not being created by the current run)"
70
+ invalid! "Unable to find #{type} #{id} (does not exist and is not being created by the current run)"
70
71
  end
71
72
  end
72
73
 
@@ -55,7 +55,7 @@ module Kennel
55
55
 
56
56
  def resolve_linked_tracking_ids(id_map)
57
57
  as_json[:monitor_ids] = as_json[:monitor_ids].map do |id|
58
- id.is_a?(String) ? resolve_link(id, id_map) : id
58
+ id.is_a?(String) ? resolve_link(id, :monitor, id_map) : id
59
59
  end
60
60
  end
61
61
 
@@ -147,7 +147,8 @@ module Kennel
147
147
  def print_plan(step, list, color)
148
148
  return if list.empty?
149
149
  list.each do |_, e, a, diff|
150
- Kennel.out.puts Utils.color(color, "#{step} #{tracking_id(e&.as_json || a)}")
150
+ api_resource = (e ? e.class.api_resource : a.fetch(:api_resource))
151
+ Kennel.out.puts Utils.color(color, "#{step} #{api_resource} #{tracking_id(e&.as_json || a)}")
151
152
  print_diff(diff) if diff # only for update
152
153
  end
153
154
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.61.2"
3
+ VERSION = "1.62.1"
4
4
  end
@@ -6,8 +6,7 @@ Keep datadog monitors/dashboards/etc in version control, avoid chaotic managemen
6
6
 
7
7
  - Documented, reusable, automated, and searchable configuration
8
8
  - Changes are PR reviewed and auditable
9
- - Good defaults like no-data / re-notify are preselected
10
- - Reliable cleanup with automated deletion
9
+ - Automated deletion when removed from code
11
10
 
12
11
  ![](github/screen.png?raw=true)
13
12
 
@@ -15,7 +14,7 @@ Keep datadog monitors/dashboards/etc in version control, avoid chaotic managemen
15
14
 
16
15
  - `projects/` monitors/dashboards/etc scoped by project
17
16
  - `teams/` team definitions
18
- - `parts/` monitors/dashes/etc that are used by multiple projects
17
+ - `parts/` monitors/dashboards/etc that are used by multiple projects
19
18
  - `generated/` projects as json, to show current state and proposed changes in PRs
20
19
 
21
20
  ## Workflows
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.61.2
4
+ version: 1.62.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: 2019-12-24 00:00:00.000000000 Z
11
+ date: 2020-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.7.6
105
+ rubygems_version: 2.7.6.2
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Keep datadog monitors/dashboards/etc in version control, avoid chaotic management