kennel 1.82.0 → 1.83.0

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: 97ae92e1ab137731096bbedde401059fc2b8d411ff667df489056f05a3cf42aa
4
- data.tar.gz: c48683c4888e16da817885a44a876638086c32e8e370aaf16553c31b7fde0136
3
+ metadata.gz: 5c3c766383bf7f533e74b935a6faf2272e552bb7c974fa15261c70aa9d31e800
4
+ data.tar.gz: 339c1dcad92fc215d2a26b7091bbe57dc98d3f6ed5a01666e1ee683162bf20e0
5
5
  SHA512:
6
- metadata.gz: 89f7a44c794130ecd4a4238ace5846d050412fd923cc5ae358cb469370c3dd380569bffe991b2251bc80baf4e183bd765591295b043ffc51fd88c5593b723f21
7
- data.tar.gz: 4a9eece67d3f0e0cf8dd56a21440ce585397d531c4aa82d1d4c3d43db08169b57dd1e982ba74e68326ae61ed8278ac4d5fed7eefe8f6979dcf5a3c3a3e98ceb0
6
+ metadata.gz: 97abfc77652ab1afb6192c97f038dc6caa33a2f8aa505c62c6782fef1359b431d93cf293c737d9f2ed03c9bb4d22d0474ac916586aa7ed15863900dc8eb1791d
7
+ data.tar.gz: 13e247e4ab000410155b9f4835686168a2017c1ee2fd8b4e0f6619c54f0b055581b1acc855d12ac06b0ed3920782722fbffa1d303ea7aa04ed92104ab1ec6908
data/Readme.md CHANGED
@@ -273,9 +273,19 @@ Run `rake kennel:alerts TAG=service:my-service` to see all un-muted alerts for a
273
273
 
274
274
  ### Grepping through all of datadog
275
275
 
276
- `rake kennel:dump`
276
+ ```Bash
277
+ rake kennel:dump > tmp/dump
278
+ cat tmp/dump | grep foo
279
+ ```
277
280
  focus on a single type: `TYPE=monitors`
278
281
 
282
+ Show full resources or just their urls by pattern:
283
+ ```Bash
284
+ rake kennel:dump_grep DUMP=tmp/dump PATTERN=foo URLS=true
285
+ https://foo.datadog.com/dasboard/123
286
+ https://foo.datadog.com/monitor/123
287
+ ```
288
+
279
289
  ### Find all monitors with No-Data
280
290
 
281
291
  `rake kennel:nodata TAG=team:foo`
@@ -123,7 +123,7 @@ module Kennel
123
123
  @json
124
124
  end
125
125
 
126
- def url(id)
126
+ def self.url(id)
127
127
  Utils.path_to_url "/dashboard/#{id}"
128
128
  end
129
129
 
@@ -125,7 +125,7 @@ module Kennel
125
125
  "monitor"
126
126
  end
127
127
 
128
- def url(id)
128
+ def self.url(id)
129
129
  Utils.path_to_url "/monitors##{id}/edit"
130
130
  end
131
131
 
@@ -18,6 +18,10 @@ module Kennel
18
18
  end
19
19
  end
20
20
 
21
+ def api_resource_map
22
+ subclasses.map { |s| [s.api_resource, s] }.to_h
23
+ end
24
+
21
25
  private
22
26
 
23
27
  def normalize(_expected, actual)
@@ -58,7 +58,7 @@ module Kennel
58
58
  "slo"
59
59
  end
60
60
 
61
- def url(id)
61
+ def self.url(id)
62
62
  Utils.path_to_url "/slo?slo_id=#{id}"
63
63
  end
64
64
 
data/lib/kennel/syncer.rb CHANGED
@@ -41,12 +41,12 @@ module Kennel
41
41
  reply = @api.create e.class.api_resource, e.as_json
42
42
  id = reply.fetch(:id)
43
43
  populate_id_map [reply] # allow resolving ids we could previously no resolve
44
- Kennel.out.puts "Created #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.url(id)}"
44
+ Kennel.out.puts "Created #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.class.url(id)}"
45
45
  end
46
46
 
47
47
  each_resolved @update do |id, e|
48
48
  @api.update e.class.api_resource, id, e.as_json
49
- Kennel.out.puts "Updated #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.url(id)}"
49
+ Kennel.out.puts "Updated #{e.class.api_resource} #{tracking_id(e.as_json)} #{e.class.url(id)}"
50
50
  end
51
51
 
52
52
  @delete.each do |id, _, a|
data/lib/kennel/tasks.rb CHANGED
@@ -130,7 +130,7 @@ namespace :kennel do
130
130
  if type = ENV["TYPE"]
131
131
  [type]
132
132
  else
133
- Kennel::Models::Record.subclasses.map(&:api_resource)
133
+ Kennel::Models::Record.api_resource_map.keys
134
134
  end
135
135
  api = Kennel.send(:api)
136
136
  list = nil
@@ -141,11 +141,30 @@ namespace :kennel do
141
141
  api.fill_details!(resource, list)
142
142
  end
143
143
  list.each do |r|
144
+ r[:api_resource] = resource
144
145
  Kennel.out.puts JSON.pretty_generate(r)
145
146
  end
146
147
  end
147
148
  end
148
149
 
150
+ desc "Find items from dump by pattern DUMP= PATTERN= [URLS=true]"
151
+ task dump_grep: :environment do
152
+ file = ENV.fetch("DUMP")
153
+ pattern = Regexp.new ENV.fetch("PATTERN")
154
+ items = File.read(file).gsub("}\n{", "}--SPLIT--{").split("--SPLIT--")
155
+ models = Kennel::Models::Record.api_resource_map
156
+ found = items.grep(pattern)
157
+ exit 1 if found.empty?
158
+ found.each do |resource|
159
+ if ENV["URLS"]
160
+ parsed = JSON.parse(resource)
161
+ Kennel.out.puts models[parsed.fetch("api_resource")].url(parsed.fetch("id"))
162
+ else
163
+ Kennel.out.puts resource
164
+ end
165
+ end
166
+ end
167
+
149
168
  task :environment do
150
169
  require "kennel"
151
170
  gem "dotenv"
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.82.0"
3
+ VERSION = "1.83.0"
4
4
  end
data/template/Readme.md CHANGED
@@ -255,9 +255,19 @@ Run `rake kennel:alerts TAG=service:my-service` to see all un-muted alerts for a
255
255
 
256
256
  ### Grepping through all of datadog
257
257
 
258
- `rake kennel:dump`
258
+ ```Bash
259
+ rake kennel:dump > tmp/dump
260
+ cat tmp/dump | grep foo
261
+ ```
259
262
  focus on a single type: `TYPE=monitors`
260
263
 
264
+ Show full resources or just their urls by pattern:
265
+ ```Bash
266
+ rake kennel:dump_grep DUMP=tmp/dump PATTERN=foo URLS=true
267
+ https://foo.datadog.com/dasboard/123
268
+ https://foo.datadog.com/monitor/123
269
+ ```
270
+
261
271
  ### Find all monitors with No-Data
262
272
 
263
273
  `rake kennel:nodata TAG=team:foo`
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: 1.82.0
4
+ version: 1.83.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser