kennel 1.61.0 → 1.61.5

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: b27c8e5ce2f9b7ec5b649d582ff591bd05b2c874fdbf21207db795d3cc5b6c26
4
- data.tar.gz: a1385e625b05f60d80d9cb5b6ca89a97cd9099187bb24896fee4e1bdcdcf51b3
3
+ metadata.gz: c170afd5f8bc8223b9b7d37bf48a1de593d643fa7de785ec8fc26e631bcdf81c
4
+ data.tar.gz: 89ec3660c0b7a1022a104a6d6b51eda9ec3291a1bb9cf46d2ae303597e66c30b
5
5
  SHA512:
6
- metadata.gz: 32273b702f893078015f99518c2798b3aa30dbd81abc68802ff35765ee489a2a16d0ad5f270c2d824c3d54fd44d4fba48d554486c19683a113f3a9e87f6ce1cd
7
- data.tar.gz: 0f3c9290832283f5d1ae08865b926e84c7ba34fa8c79ebb01ddad91dad16eb592e54b9e246e432a00d7c2334908180b31cb2d343ce719a75c39b9cb4cf691ce2
6
+ metadata.gz: a68a43cf73743f9f098259dd5c614cdc6ced148d08cf629907f090689804148e01e857a4434f9410607fec338e3cca50f883e4dfe31200e48b80dffbbb7ff379
7
+ data.tar.gz: d5c5bf8a43c526611162267d6c4babb64a57aab4d0eddbb0cbf9e1fb507f0066528c6e82f7651911fdfd86d74c6ae520b634c7b0de1b799d8d55a1c695f0e457
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
@@ -91,7 +91,7 @@ module Kennel
91
91
  # [a, e] -> [[a-w, e-w], [a-w1-w1, e-w1-w1], ...]
92
92
  def widgets_pairs(*pair)
93
93
  result = [pair.map { |d| d[:widgets] || [] }]
94
- slots = result.compact.map(&:size).max.to_i
94
+ slots = result[0].map(&:size).max
95
95
  slots.times do |i|
96
96
  nested = pair.map { |d| d.dig(:widgets, i, :definition, :widgets) || [] }
97
97
  result << nested if nested.any?(&:any?)
@@ -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
@@ -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
@@ -25,7 +25,7 @@ module Kennel
25
25
  if bad.any?
26
26
  invalid!(
27
27
  "queries #{bad.join(", ")} must use the template variables #{variables.join(", ")}\n" \
28
- "If that is not possible, add `validate_template_variables: -> { false } # query foo in bar does not have baz tag`"
28
+ "If that is not possible, add `validate: -> { false } # query foo in bar does not have baz tag`"
29
29
  )
30
30
  end
31
31
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.61.0"
3
+ VERSION = "1.61.5"
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.0
4
+ version: 1.61.5
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-20 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