kennel 1.10.2 → 1.11.0
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/lib/kennel/models/base.rb +4 -0
- data/lib/kennel/models/monitor.rb +17 -1
- data/lib/kennel/version.rb +1 -1
- 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: 7f3b1eb54a6d3249228c90e6313b1b014ce75463da52f3bf9a242ab81aa45b84
|
4
|
+
data.tar.gz: 1e2650fc9d44b68e91336afea05f711b90bca96bb571be027404ad103d94043b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 603e35948978e66351219b4b34d3ae35ef3d95a48f77a6ebed8fdc167edcba73ebf2be8910779ce62354f2ce34df9a457a882aaef18aac938e58ed6792476482
|
7
|
+
data.tar.gz: 37c00fd53b6767e7f49592eb6f46d63e13289bf64fac7dbbb339a22cb12b51f7bddd2d0a685c95968dda972cb0d1e3a4a0c188ad40a7b52a1b92d5ea4298e73b
|
data/lib/kennel/models/base.rb
CHANGED
@@ -95,6 +95,10 @@ module Kennel
|
|
95
95
|
"#{project.kennel_id}:#{kennel_id}"
|
96
96
|
end
|
97
97
|
|
98
|
+
def to_json
|
99
|
+
raise NotImplementedError, "Use as_json"
|
100
|
+
end
|
101
|
+
|
98
102
|
private
|
99
103
|
|
100
104
|
# discard styles/conditional_formats/aggregator if nothing would change when we applied (both are default or nil)
|
@@ -138,30 +138,46 @@ module Kennel
|
|
138
138
|
def validate_json(data)
|
139
139
|
type = data.fetch(:type)
|
140
140
|
|
141
|
+
# do not allow deprecated type that will be coverted by datadog and then produce a diff
|
141
142
|
if type == "metric alert"
|
142
143
|
invalid! "type 'metric alert' is deprecated, do not set type to use the default 'query alert'"
|
143
144
|
end
|
144
145
|
|
146
|
+
# verify service checks use interger thresholds to avoid diff
|
145
147
|
if type == "service check" && [ok, warning, critical].compact.map(&:class).uniq != [Integer]
|
146
148
|
invalid! ":ok, :warning and :critical must be integers for service check type"
|
147
149
|
end
|
148
150
|
|
151
|
+
# verify query includes critical value
|
149
152
|
if query_value = data.fetch(:query)[/\s*[<>]\s*(\d+(\.\d+)?)\s*$/, 1]
|
150
153
|
if Float(query_value) != Float(data.dig(:options, :thresholds, :critical))
|
151
154
|
invalid! "critical and value used in query must match"
|
152
155
|
end
|
153
156
|
end
|
154
157
|
|
158
|
+
# verify renotify interval is valid
|
155
159
|
unless RENOTIFY_INTERVALS.include? data.dig(:options, :renotify_interval)
|
156
160
|
invalid! "renotify_interval must be one of #{RENOTIFY_INTERVALS.join(", ")}"
|
157
161
|
end
|
158
162
|
|
159
|
-
if
|
163
|
+
if type == "query alert"
|
164
|
+
# verify interval is valud
|
160
165
|
interval = data.fetch(:query)[/\(last_(\S+?)\)/, 1]
|
161
166
|
unless QUERY_INTERVALS.include?(interval)
|
162
167
|
invalid! "query interval was #{interval}, but must be one of #{QUERY_INTERVALS.join(", ")}"
|
163
168
|
end
|
164
169
|
end
|
170
|
+
|
171
|
+
if ["query alert", "service check"].include?(type) # TODO: most likely more types need this
|
172
|
+
# verify is_match uses available variables
|
173
|
+
message = data.fetch(:message)
|
174
|
+
used = message.scan(/{{\s*#is_match\s*"([a-zA-Z\d_.-]+).name"/).flatten.uniq
|
175
|
+
allowed = data.fetch(:query)[/by\s*{([^\}]+)}/, 1].to_s.split(/\s*,\s*/)
|
176
|
+
unsupported = used - allowed
|
177
|
+
if unsupported.any?
|
178
|
+
invalid! "is_match used with unsupported dimensions #{unsupported}, allowed dimensions are #{allowed}"
|
179
|
+
end
|
180
|
+
end
|
165
181
|
end
|
166
182
|
end
|
167
183
|
end
|
data/lib/kennel/version.rb
CHANGED
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.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|