kennel 1.57.2 → 1.58.4
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/api.rb +16 -1
- data/lib/kennel/models/slo.rb +11 -2
- data/lib/kennel/tasks.rb +19 -8
- data/lib/kennel/version.rb +1 -1
- data/template/Readme.md +1 -0
- 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: bb7f29450cced9fd421dd64c7dacf109d3e3fe93245f19bfcec695b98491f559
|
4
|
+
data.tar.gz: d1db2105b3f6566f74b71476e089d9691ad9f8f5b3ff08e27801668d172dd6ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b147725c2c13a0ef72771380a9e55518983d2876b6d90a94af2917ca9fe59ef297123ed4ec8d52b2c9cf41f51536b4b3ce0541321e91d8f8649c140de7a031d5
|
7
|
+
data.tar.gz: dbaaa1cd7d9d57cd1d78be0e50e21b27723da7b35f6993cfea5c61b882564abb44c1027461ea4fd7f4794ad3b72f11e068cdb0a50cd6904d01f9badcfa8e76af
|
data/Readme.md
CHANGED
@@ -45,6 +45,7 @@ Keep datadog monitors/dashboards/etc in version control, avoid chaotic managemen
|
|
45
45
|
- copy any `API Key` and add it to `.env` as `DATADOG_API_KEY`
|
46
46
|
- find or create (check last page) your personal "Application Key" and add it to `.env` as `DATADOG_APP_KEY=`
|
47
47
|
- change the `DATADOG_SUBDOMAIN=app` in `.env` to your companies subdomain if you have one
|
48
|
+
- verify it works by running `rake plan`, it might show some diff, but should not crash
|
48
49
|
-->
|
49
50
|
|
50
51
|
### Adding a team
|
data/lib/kennel/api.rb
CHANGED
@@ -13,7 +13,22 @@ module Kennel
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def list(api_resource, params = {})
|
16
|
-
|
16
|
+
if api_resource == "slo"
|
17
|
+
raise ArgumentError if params[:limit] || params[:offset]
|
18
|
+
limit = 1000
|
19
|
+
offset = 0
|
20
|
+
all = []
|
21
|
+
|
22
|
+
loop do
|
23
|
+
result = request :get, "/api/v1/#{api_resource}", params: params.merge(limit: limit, offset: offset)
|
24
|
+
data = result.fetch(:data)
|
25
|
+
all.concat data
|
26
|
+
break all if data.size < limit
|
27
|
+
offset += limit
|
28
|
+
end
|
29
|
+
else
|
30
|
+
request :get, "/api/v1/#{api_resource}", params: params
|
31
|
+
end
|
17
32
|
end
|
18
33
|
|
19
34
|
def create(api_resource, attributes)
|
data/lib/kennel/models/slo.rb
CHANGED
@@ -6,7 +6,8 @@ module Kennel
|
|
6
6
|
DEFAULTS = {
|
7
7
|
description: nil,
|
8
8
|
query: nil,
|
9
|
-
monitor_ids: []
|
9
|
+
monitor_ids: [],
|
10
|
+
thresholds: []
|
10
11
|
}.freeze
|
11
12
|
|
12
13
|
settings :type, :description, :thresholds, :query, :tags, :monitor_ids, :monitor_tags, :name
|
@@ -16,9 +17,17 @@ module Kennel
|
|
16
17
|
tags: -> { @project.tags },
|
17
18
|
query: -> { DEFAULTS.fetch(:query) },
|
18
19
|
description: -> { DEFAULTS.fetch(:description) },
|
19
|
-
monitor_ids: -> { DEFAULTS.fetch(:monitor_ids) }
|
20
|
+
monitor_ids: -> { DEFAULTS.fetch(:monitor_ids) },
|
21
|
+
thresholds: -> { DEFAULTS.fetch(:thresholds) }
|
20
22
|
)
|
21
23
|
|
24
|
+
def initialize(*)
|
25
|
+
super
|
26
|
+
if thresholds.any? { |t| t[:warning] && t[:warning].to_f <= t[:critical].to_f }
|
27
|
+
raise ValidationError, "Threshold warning must be greater-than critical value"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
22
31
|
def as_json
|
23
32
|
return @as_json if @as_json
|
24
33
|
data = {
|
data/lib/kennel/tasks.rb
CHANGED
@@ -4,12 +4,23 @@ require "kennel"
|
|
4
4
|
require "kennel/unmuted_alerts"
|
5
5
|
require "kennel/importer"
|
6
6
|
|
7
|
+
module Kennel
|
8
|
+
module Tasks
|
9
|
+
class << self
|
10
|
+
def abort(message = nil)
|
11
|
+
Kennel.err.puts message if message
|
12
|
+
raise SystemExit.new(1), message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
7
18
|
namespace :kennel do
|
8
19
|
desc "Ensure there are no uncommited changes that would be hidden from PR reviewers"
|
9
20
|
task no_diff: :generate do
|
10
21
|
result = `git status --porcelain`.strip
|
11
|
-
abort "Diff found:\n#{result}\nrun `rake generate` and commit the diff to fix" unless result == ""
|
12
|
-
abort "Error during diffing" unless $CHILD_STATUS.success?
|
22
|
+
Kennel::Tasks.abort "Diff found:\n#{result}\nrun `rake generate` and commit the diff to fix" unless result == ""
|
23
|
+
Kennel::Tasks.abort "Error during diffing" unless $CHILD_STATUS.success?
|
13
24
|
end
|
14
25
|
|
15
26
|
# ideally do this on every run, but it's slow (~1.5s) and brittle (might not find all + might find false-positives)
|
@@ -38,7 +49,7 @@ namespace :kennel do
|
|
38
49
|
url = (subdomain ? "https://zendesk.datadoghq.com" : "") + "/account/settings"
|
39
50
|
puts "Invalid mentions found, either ignore them by adding to `KNOWN` env var or add them via #{url}"
|
40
51
|
bad.each { |f, v| puts "Invalid mention #{v} in monitor message of #{f}" }
|
41
|
-
abort
|
52
|
+
Kennel::Tasks.abort
|
42
53
|
end
|
43
54
|
end
|
44
55
|
|
@@ -76,16 +87,16 @@ namespace :kennel do
|
|
76
87
|
|
77
88
|
desc "show unmuted alerts filtered by TAG, for example TAG=team:foo"
|
78
89
|
task alerts: :environment do
|
79
|
-
tag = ENV["TAG"] || abort("Call with TAG=foo:bar")
|
90
|
+
tag = ENV["TAG"] || Kennel::Tasks.abort("Call with TAG=foo:bar")
|
80
91
|
Kennel::UnmutedAlerts.print(Kennel.send(:api), tag)
|
81
92
|
end
|
82
93
|
|
83
94
|
desc "show monitors with no data by TAG, for example TAG=team:foo"
|
84
95
|
task nodata: :environment do
|
85
|
-
tag = ENV["TAG"] || abort("Call with TAG=foo:bar")
|
96
|
+
tag = ENV["TAG"] || Kennel::Tasks.abort("Call with TAG=foo:bar")
|
86
97
|
monitors = Kennel.send(:api).list("monitor", monitor_tags: tag, group_states: "no data")
|
87
98
|
monitors.select! { |m| m[:overall_state] == "No Data" }
|
88
|
-
monitors.reject! { |m| m[:tags].include?
|
99
|
+
monitors.reject! { |m| m[:tags].include? "nodata:ignore" }
|
89
100
|
if monitors.any?
|
90
101
|
Kennel.err.puts <<~TEXT
|
91
102
|
This is a useful task to find monitors that have mis-spelled metrics or never received data at any time.
|
@@ -103,8 +114,8 @@ namespace :kennel do
|
|
103
114
|
|
104
115
|
desc "Convert existing resources to copy-pastable definitions to import existing resources RESOURCE=dash ID=1234"
|
105
116
|
task import: :environment do
|
106
|
-
resource = ENV["RESOURCE"] || abort("Call with RESOURCE=dash") # TODO: add others
|
107
|
-
id = ENV["ID"] || abort("Call with ID=1234")
|
117
|
+
resource = ENV["RESOURCE"] || Kennel::Tasks.abort("Call with RESOURCE=dash") # TODO: add others
|
118
|
+
id = ENV["ID"] || Kennel::Tasks.abort("Call with ID=1234")
|
108
119
|
id = Integer(id) if id =~ /^\d+$/ # dashboards can have alphanumeric ids
|
109
120
|
puts Kennel::Importer.new(Kennel.send(:api)).import(resource, id)
|
110
121
|
end
|
data/lib/kennel/version.rb
CHANGED
data/template/Readme.md
CHANGED
@@ -28,6 +28,7 @@ Keep datadog monitors/dashboards/etc in version control, avoid chaotic managemen
|
|
28
28
|
- copy any `API Key` and add it to `.env` as `DATADOG_API_KEY`
|
29
29
|
- find or create (check last page) your personal "Application Key" and add it to `.env` as `DATADOG_APP_KEY=`
|
30
30
|
- change the `DATADOG_SUBDOMAIN=app` in `.env` to your companies subdomain if you have one
|
31
|
+
- verify it works by running `rake plan`, it might show some diff, but should not crash
|
31
32
|
|
32
33
|
### Adding a team
|
33
34
|
|
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.58.4
|
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-
|
11
|
+
date: 2019-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|