kennel 1.69.0 → 1.72.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 +4 -4
- data/Readme.md +3 -3
- data/lib/kennel/github_reporter.rb +1 -0
- data/lib/kennel/models/dashboard.rb +11 -1
- data/lib/kennel/models/monitor.rb +7 -1
- data/lib/kennel/models/record.rb +8 -0
- data/lib/kennel/models/slo.rb +4 -0
- data/lib/kennel/syncer.rb +1 -1
- data/lib/kennel/tasks.rb +13 -9
- data/lib/kennel/utils.rb +1 -0
- data/lib/kennel/version.rb +1 -1
- data/template/Readme.md +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9dec3dd3c3595176bc3340b7fcfd0227cca53a09ab56db9911da90546f8cc125
|
|
4
|
+
data.tar.gz: '019ee1e8e9c7e37d3218f77790ab5cc5ef08504fd0a603ee710a4623e36f72fa'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a49dda9dcff0d0a8d330a68f2c9a6e69fb20624067bc24b9fae57c3e7f9cfe94ea9f3cb412acc456a4743ca5b61643a7494e5599833d296e92893372ee39be9a
|
|
7
|
+
data.tar.gz: 11a86599302eb683e8b7f37df641af3d0965ac52ace5ee00375d2a3644cc35e0b4844c31f1cdd71a98a9eec5e91002a7b20d23a611dd51ce902de5c93df462cf
|
data/Readme.md
CHANGED
|
@@ -23,7 +23,7 @@ Manage datadog monitors/dashboards/slos as code
|
|
|
23
23
|
```
|
|
24
24
|
- add a basic projects and teams so others can copy-paste to get started
|
|
25
25
|
- setup travis build for your repo
|
|
26
|
-
- uncomment `.travis.yml` section for automated
|
|
26
|
+
- uncomment `.travis.yml` section for automated PR planing and datadog updates on merge
|
|
27
27
|
- follow `Setup` in your repos Readme.md
|
|
28
28
|
<!-- NOT IN -->
|
|
29
29
|
|
|
@@ -72,7 +72,7 @@ end
|
|
|
72
72
|
### Updating an existing monitor
|
|
73
73
|
- use [datadog monitor UI](https://app.datadoghq.com/monitors/manage) to find a monitor
|
|
74
74
|
- get the `id` from the url
|
|
75
|
-
- run `
|
|
75
|
+
- run `URL='https://app.datadoghq.com/monitors/123' bundle exec rake kennel:import` and copy the output
|
|
76
76
|
- find or create a project in `projects/`
|
|
77
77
|
- add the monitor to `parts: [` list, for example:
|
|
78
78
|
```Ruby
|
|
@@ -118,7 +118,7 @@ end
|
|
|
118
118
|
### Updating an existing dashboard
|
|
119
119
|
- go to [datadog dashboard UI](https://app.datadoghq.com/dashboard/lists) and click on _New Dashboard_ to find a dashboard
|
|
120
120
|
- get the `id` from the url
|
|
121
|
-
- run `
|
|
121
|
+
- run `URL='https://app.datadoghq.com/dashboard/bet-foo-bar' bundle exec rake kennel:import` and copy the output
|
|
122
122
|
- find or create a project in `projects/`
|
|
123
123
|
- add a dashboard to `parts: [` list, for example:
|
|
124
124
|
```Ruby
|
|
@@ -16,12 +16,13 @@ module Kennel
|
|
|
16
16
|
TIMESERIES_DEFAULTS = { show_legend: false, legend_size: "0" }.freeze
|
|
17
17
|
SUPPORTED_DEFINITION_OPTIONS = [:events, :markers, :precision].freeze
|
|
18
18
|
|
|
19
|
-
settings :title, :description, :definitions, :widgets, :layout_type
|
|
19
|
+
settings :title, :description, :definitions, :widgets, :layout_type, :template_variable_presets
|
|
20
20
|
|
|
21
21
|
defaults(
|
|
22
22
|
description: -> { "" },
|
|
23
23
|
definitions: -> { [] },
|
|
24
24
|
widgets: -> { [] },
|
|
25
|
+
template_variable_presets: -> { [] },
|
|
25
26
|
id: -> { nil }
|
|
26
27
|
)
|
|
27
28
|
|
|
@@ -102,6 +103,7 @@ module Kennel
|
|
|
102
103
|
title: "#{title}#{LOCK}",
|
|
103
104
|
description: description,
|
|
104
105
|
template_variables: render_template_variables,
|
|
106
|
+
template_variable_presets: template_variable_presets,
|
|
105
107
|
widgets: all_widgets
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -116,6 +118,10 @@ module Kennel
|
|
|
116
118
|
Utils.path_to_url "/dashboard/#{id}"
|
|
117
119
|
end
|
|
118
120
|
|
|
121
|
+
def self.parse_url(url)
|
|
122
|
+
url[/\/dashboard\/([a-z\d-]+)/, 1]
|
|
123
|
+
end
|
|
124
|
+
|
|
119
125
|
def resolve_linked_tracking_ids(id_map)
|
|
120
126
|
widgets = as_json[:widgets].flat_map { |w| [w, *w.dig(:definition, :widgets) || []] }
|
|
121
127
|
widgets.each do |widget|
|
|
@@ -163,6 +169,10 @@ module Kennel
|
|
|
163
169
|
super
|
|
164
170
|
|
|
165
171
|
validate_template_variables data, :widgets
|
|
172
|
+
|
|
173
|
+
# Avoid diff from datadog presets sorting.
|
|
174
|
+
presets = data[:template_variable_presets]
|
|
175
|
+
invalid! "template_variable_presets must be sorted by name" if presets != presets.sort_by { |p| p[:name] }
|
|
166
176
|
end
|
|
167
177
|
|
|
168
178
|
def render_definitions
|
|
@@ -120,6 +120,12 @@ module Kennel
|
|
|
120
120
|
Utils.path_to_url "/monitors##{id}/edit"
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
+
# datadog uses both / and # as separator in it's links
|
|
124
|
+
def self.parse_url(url)
|
|
125
|
+
return unless id = url[/\/monitors[\/#](\d+)/, 1]
|
|
126
|
+
Integer(id)
|
|
127
|
+
end
|
|
128
|
+
|
|
123
129
|
def self.normalize(expected, actual)
|
|
124
130
|
super
|
|
125
131
|
options = actual.fetch(:options)
|
|
@@ -196,7 +202,7 @@ module Kennel
|
|
|
196
202
|
# verify is_match uses available variables
|
|
197
203
|
message = data.fetch(:message)
|
|
198
204
|
used = message.scan(/{{\s*#is_match\s*"([a-zA-Z\d_.-]+).name"/).flatten.uniq
|
|
199
|
-
allowed = data.fetch(:query)[/by\s*{([^\}]+)}/, 1].to_s.split(/\s*,\s*/)
|
|
205
|
+
allowed = data.fetch(:query)[/by\s*[\({]([^\}\)]+)[}\)]/, 1].to_s.gsub(/["']/, "").split(/\s*,\s*/)
|
|
200
206
|
unsupported = used - allowed
|
|
201
207
|
if unsupported.any?
|
|
202
208
|
invalid! "is_match used with #{unsupported}, but metric is only grouped by #{allowed}"
|
data/lib/kennel/models/record.rb
CHANGED
data/lib/kennel/models/slo.rb
CHANGED
|
@@ -62,6 +62,10 @@ module Kennel
|
|
|
62
62
|
Utils.path_to_url "/slo?slo_id=#{id}"
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
def self.parse_url(url)
|
|
66
|
+
url[/\/slo\?slo_id=([a-z\d]+)/, 1]
|
|
67
|
+
end
|
|
68
|
+
|
|
65
69
|
def resolve_linked_tracking_ids(id_map)
|
|
66
70
|
as_json[:monitor_ids] = as_json[:monitor_ids].map do |id|
|
|
67
71
|
id.is_a?(String) ? resolve_link(id, :monitor, id_map) : id
|
data/lib/kennel/syncer.rb
CHANGED
|
@@ -228,7 +228,7 @@ module Kennel
|
|
|
228
228
|
json = e.as_json
|
|
229
229
|
field = tracking_field(json)
|
|
230
230
|
value = json[field]
|
|
231
|
-
json[field] = value.dup.sub!(/\n
|
|
231
|
+
json[field] = value.dup.sub!(/\n?-- Managed by kennel .*/, "") || raise("did not find tracking id in #{value}")
|
|
232
232
|
end
|
|
233
233
|
|
|
234
234
|
def tracking_id(a)
|
data/lib/kennel/tasks.rb
CHANGED
|
@@ -68,7 +68,7 @@ namespace :kennel do
|
|
|
68
68
|
Kennel.update
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
desc "update if this is a push to the default branch, otherwise plan
|
|
71
|
+
desc "update if this is a push to the default branch, otherwise plan"
|
|
72
72
|
task :travis do
|
|
73
73
|
on_default_branch = (ENV["TRAVIS_BRANCH"] == (ENV["DEFAULT_BRANCH"] || "master"))
|
|
74
74
|
is_push = (ENV["TRAVIS_PULL_REQUEST"] == "false")
|
|
@@ -79,9 +79,7 @@ namespace :kennel do
|
|
|
79
79
|
"kennel:plan" # show plan in travis logs
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
Rake::Task[task_name].invoke
|
|
84
|
-
end
|
|
82
|
+
Rake::Task[task_name].invoke
|
|
85
83
|
end
|
|
86
84
|
|
|
87
85
|
desc "show unmuted alerts filtered by TAG, for example TAG=team:foo"
|
|
@@ -111,12 +109,18 @@ namespace :kennel do
|
|
|
111
109
|
end
|
|
112
110
|
end
|
|
113
111
|
|
|
114
|
-
desc "Convert existing resources to copy-
|
|
112
|
+
desc "Convert existing resources to copy-pasteable definitions to import existing resources (call with URL= or call with RESOURCE= and ID=)"
|
|
115
113
|
task import: :environment do
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
114
|
+
if (id = ENV["ID"]) && (resource = ENV["RESOURCE"])
|
|
115
|
+
id = Integer(id) if id =~ /^\d+$/ # dashboards can have alphanumeric ids
|
|
116
|
+
elsif (url = ENV["URL"])
|
|
117
|
+
resource, id = Kennel::Models::Record.parse_any_url(url) || Kennel::Tasks.abort("Unable to parse url")
|
|
118
|
+
else
|
|
119
|
+
possible_resources = Kennel::Models::Record.subclasses.map(&:api_resource)
|
|
120
|
+
Kennel::Tasks.abort("Call with URL= or call with RESOURCE=#{possible_resources.join(" or ")} and ID=")
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
Kennel.out.puts Kennel::Importer.new(Kennel.send(:api)).import(resource, id)
|
|
120
124
|
end
|
|
121
125
|
|
|
122
126
|
desc "Dump ALL of datadog config as raw json ... useful for grep/search TYPE=slo|monitor|dashboard"
|
data/lib/kennel/utils.rb
CHANGED
data/lib/kennel/version.rb
CHANGED
data/template/Readme.md
CHANGED
|
@@ -54,7 +54,7 @@ end
|
|
|
54
54
|
### Updating an existing monitor
|
|
55
55
|
- use [datadog monitor UI](https://app.datadoghq.com/monitors/manage) to find a monitor
|
|
56
56
|
- get the `id` from the url
|
|
57
|
-
- run `
|
|
57
|
+
- run `URL='https://app.datadoghq.com/monitors/123' bundle exec rake kennel:import` and copy the output
|
|
58
58
|
- find or create a project in `projects/`
|
|
59
59
|
- add the monitor to `parts: [` list, for example:
|
|
60
60
|
```Ruby
|
|
@@ -100,7 +100,7 @@ end
|
|
|
100
100
|
### Updating an existing dashboard
|
|
101
101
|
- go to [datadog dashboard UI](https://app.datadoghq.com/dashboard/lists) and click on _New Dashboard_ to find a dashboard
|
|
102
102
|
- get the `id` from the url
|
|
103
|
-
- run `
|
|
103
|
+
- run `URL='https://app.datadoghq.com/dashboard/bet-foo-bar' bundle exec rake kennel:import` and copy the output
|
|
104
104
|
- find or create a project in `projects/`
|
|
105
105
|
- add a dashboard to `parts: [` list, for example:
|
|
106
106
|
```Ruby
|
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.
|
|
4
|
+
version: 1.72.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: 2020-
|
|
11
|
+
date: 2020-06-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|