kennel 1.88.1 → 1.89.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +1 -0
- data/lib/kennel/models/base.rb +1 -1
- data/lib/kennel/models/monitor.rb +8 -2
- data/lib/kennel/models/record.rb +5 -1
- data/lib/kennel/models/slo.rb +1 -1
- data/lib/kennel/syncer.rb +11 -4
- data/lib/kennel/version.rb +1 -1
- data/template/Readme.md +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdedd0f9bbcb9abf873cd2f9be0414700f77d2ea864e609db79773d1b3193e8e
|
4
|
+
data.tar.gz: 336875475665fac019c12daced64e474fb8e85e216e158d4328b62b287785e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0041e466ce433d82f9db8252829f8c64652815d7bf932ec93596d57af76dc13aaa9dfce963bbf82888e09d424937b597364954edc1cff14344143f0661e8e274
|
7
|
+
data.tar.gz: a286f227e597686085049ef0227b2e36b26d33ef41a7d96d13a535af73e1530254de6bf68ead11ebdd0c394d1562766a91a478c794ee17f35c288a7f102d46b7
|
data/Readme.md
CHANGED
@@ -114,6 +114,7 @@ end
|
|
114
114
|
- use [datadog monitor UI](https://app.datadoghq.com/monitors/manage) to find a monitor
|
115
115
|
- get the `id` from the url
|
116
116
|
- run `URL='https://app.datadoghq.com/monitors/123' bundle exec rake kennel:import` and copy the output
|
117
|
+
- import task also works with SLO alerts, e.g. `URL='https://app.datadoghq.com/slo/edit/123abc456def123/alerts/789' bundle exec rake kennel:import`
|
117
118
|
- find or create a project in `projects/`
|
118
119
|
- add the monitor to `parts: [` list, for example:
|
119
120
|
```Ruby
|
data/lib/kennel/models/base.rb
CHANGED
@@ -11,7 +11,7 @@ module Kennel
|
|
11
11
|
|
12
12
|
def kennel_id
|
13
13
|
name = self.class.name
|
14
|
-
if name.start_with?("Kennel::")
|
14
|
+
if name.start_with?("Kennel::") # core objects would always generate the same id
|
15
15
|
raise_with_location ArgumentError, "Set :kennel_id"
|
16
16
|
end
|
17
17
|
@kennel_id ||= Utils.snake_case name
|
@@ -129,9 +129,15 @@ module Kennel
|
|
129
129
|
Utils.path_to_url "/monitors##{id}/edit"
|
130
130
|
end
|
131
131
|
|
132
|
-
# datadog uses / for show and # for edit as separator in it's links
|
133
132
|
def self.parse_url(url)
|
134
|
-
|
133
|
+
# datadog uses / for show and # for edit as separator in it's links
|
134
|
+
id = url[/\/monitors[\/#](\d+)/, 1]
|
135
|
+
|
136
|
+
# slo alert url
|
137
|
+
id ||= url[/\/slo\/edit\/[a-z\d]{10,}\/alerts\/(\d+)/, 1]
|
138
|
+
|
139
|
+
return unless id
|
140
|
+
|
135
141
|
Integer(id)
|
136
142
|
end
|
137
143
|
|
data/lib/kennel/models/record.rb
CHANGED
@@ -74,7 +74,11 @@ module Kennel
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def tracking_id
|
77
|
-
|
77
|
+
@tracking_id ||= begin
|
78
|
+
id = "#{project.kennel_id}:#{kennel_id}"
|
79
|
+
raise ValidationError, "#{id} kennel_id cannot include whitespace" if id.match?(/\s/) # <-> parse_tracking_id
|
80
|
+
id
|
81
|
+
end
|
78
82
|
end
|
79
83
|
|
80
84
|
def resolve_linked_tracking_ids!(*)
|
data/lib/kennel/models/slo.rb
CHANGED
data/lib/kennel/syncer.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
module Kennel
|
3
3
|
class Syncer
|
4
4
|
DELETE_ORDER = ["dashboard", "slo", "monitor"].freeze # dashboards references monitors + slos, slos reference monitors
|
5
|
+
LINE_UP = "\e[1A"
|
5
6
|
|
6
7
|
def initialize(api, expected, project: nil)
|
7
8
|
@api = api
|
@@ -37,23 +38,29 @@ module Kennel
|
|
37
38
|
|
38
39
|
def update
|
39
40
|
each_resolved @create do |_, e|
|
41
|
+
message = "#{e.class.api_resource} #{e.tracking_id}"
|
42
|
+
Kennel.out.puts "Creating #{message}"
|
40
43
|
reply = @api.create e.class.api_resource, e.as_json
|
41
44
|
reply[:klass] = e.class # store api resource class for later use
|
42
45
|
id = reply.fetch(:id)
|
43
46
|
populate_id_map [reply] # allow resolving ids we could previously no resolve
|
44
|
-
Kennel.out.puts "
|
47
|
+
Kennel.out.puts "#{LINE_UP}Created #{message} #{e.class.url(id)}"
|
45
48
|
end
|
46
49
|
|
47
50
|
each_resolved @update do |id, e|
|
51
|
+
message = "#{e.class.api_resource} #{e.tracking_id} #{e.class.url(id)}"
|
52
|
+
Kennel.out.puts "Updating #{message}"
|
48
53
|
@api.update e.class.api_resource, id, e.as_json
|
49
|
-
Kennel.out.puts "
|
54
|
+
Kennel.out.puts "#{LINE_UP}Updated #{message}"
|
50
55
|
end
|
51
56
|
|
52
57
|
@delete.each do |id, _, a|
|
53
58
|
klass = a.fetch(:klass)
|
54
|
-
@api.delete klass.api_resource, id
|
55
59
|
tracking_id = klass.parse_tracking_id(a)
|
56
|
-
|
60
|
+
message = "#{klass.api_resource} #{tracking_id} #{id}"
|
61
|
+
Kennel.out.puts "Deleting #{message}"
|
62
|
+
@api.delete klass.api_resource, id
|
63
|
+
Kennel.out.puts "#{LINE_UP}Deleted #{message}"
|
57
64
|
end
|
58
65
|
end
|
59
66
|
|
data/lib/kennel/version.rb
CHANGED
data/template/Readme.md
CHANGED
@@ -96,6 +96,7 @@ end
|
|
96
96
|
- use [datadog monitor UI](https://app.datadoghq.com/monitors/manage) to find a monitor
|
97
97
|
- get the `id` from the url
|
98
98
|
- run `URL='https://app.datadoghq.com/monitors/123' bundle exec rake kennel:import` and copy the output
|
99
|
+
- import task also works with SLO alerts, e.g. `URL='https://app.datadoghq.com/slo/edit/123abc456def123/alerts/789' bundle exec rake kennel:import`
|
99
100
|
- find or create a project in `projects/`
|
100
101
|
- add the monitor to `parts: [` list, for example:
|
101
102
|
```Ruby
|