kennel 1.57.0 → 1.58.2

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: 7b74c28c8a837145770672b8838930861f8c70355fe32132a234addfc6764f8c
4
- data.tar.gz: 896986fa0d5db196515468a6d6b0d81d3cfdd160f65a9616de128f5dad7d1014
3
+ metadata.gz: 27642045f1b97eac7f2a3184ccc0988a090ac9d4ad3d530120dc614a2b4e5670
4
+ data.tar.gz: 1f7d6b79d90b4fd1a5a76194af9a5c856920b190fbe0aa50b86499414976003e
5
5
  SHA512:
6
- metadata.gz: ee5e20d4bc534fc6164ae2da424e59f71266ce6af567d3f55ba047c17eac987af57aec87d5888f0b4f4f4742b818d1ffe612309895689896f1b713428d0defce
7
- data.tar.gz: dc1b244a0542b0dc304981450331bbd46b4f0c2961afb072196a000841bb5c32b4467ec2ba45c141570b4a10d37f66cda2a729dd14948515717314d0fe54268b
6
+ metadata.gz: cbd7460160bbb5e65fb1d509a1d0f9eee36229b895591f1555a1e972a2add145646fe24e3956f663bb2b0c501592cdb4a3b52b788d3811210b98a515a0d4658e
7
+ data.tar.gz: 2f896e594c59774d29d4273b885a0e4ee7ace8dcad4d3a16621d606a5b64bdb4da5ca75bb2afe52b1a137fe0d14cb46a62aa41c771830c868d3b38019a3881a2
@@ -15,7 +15,7 @@ module Kennel
15
15
  }.freeze
16
16
  SUPPORTED_DEFINITION_OPTIONS = [:events, :markers, :precision].freeze
17
17
 
18
- settings :id, :title, :description, :definitions, :widgets, :kennel_id, :layout_type
18
+ settings :title, :description, :definitions, :widgets, :layout_type
19
19
 
20
20
  defaults(
21
21
  description: -> { "" },
@@ -4,11 +4,12 @@ module Kennel
4
4
  class Monitor < Record
5
5
  include OptionalValidations
6
6
 
7
- API_LIST_INCOMPLETE = false
8
7
  RENOTIFY_INTERVALS = [0, 10, 20, 30, 40, 50, 60, 90, 120, 180, 240, 300, 360, 720, 1440].freeze # minutes
9
8
  QUERY_INTERVALS = ["1m", "5m", "10m", "15m", "30m", "1h", "2h", "4h", "1d"].freeze
10
9
  OPTIONAL_SERVICE_CHECK_THRESHOLDS = [:ok, :warning].freeze
11
- READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [:multi]
10
+ READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [
11
+ :multi, :matching_downtimes, :overall_state_modified, :overall_state
12
+ ]
12
13
 
13
14
  # defaults that datadog uses when options are not sent, so safe to leave out if our values match their defaults
14
15
  MONITOR_OPTION_DEFAULTS = {
@@ -21,8 +22,8 @@ module Kennel
21
22
  DEFAULT_ESCALATION_MESSAGE = ["", nil].freeze
22
23
 
23
24
  settings(
24
- :query, :name, :message, :escalation_message, :critical, :kennel_id, :type, :renotify_interval, :warning, :timeout_h, :evaluation_delay,
25
- :ok, :id, :no_data_timeframe, :notify_no_data, :notify_audit, :tags, :critical_recovery, :warning_recovery, :require_full_window,
25
+ :query, :name, :message, :escalation_message, :critical, :type, :renotify_interval, :warning, :timeout_h, :evaluation_delay,
26
+ :ok, :no_data_timeframe, :notify_no_data, :notify_audit, :tags, :critical_recovery, :warning_recovery, :require_full_window,
26
27
  :threshold_windows, :new_host_delay
27
28
  )
28
29
 
@@ -4,18 +4,20 @@ module Kennel
4
4
  class Record < Base
5
5
  LOCK = "\u{1F512}"
6
6
  READONLY_ATTRIBUTES = [
7
- :deleted, :matching_downtimes, :id, :created, :created_at, :creator, :org_id, :modified,
8
- :modified_at, :overall_state_modified, :overall_state, :api_resource
7
+ :deleted, :id, :created, :created_at, :creator, :org_id, :modified, :modified_at, :api_resource
9
8
  ].freeze
10
9
  REQUEST_DEFAULTS = {
11
10
  style: { width: "normal", palette: "dog_classic", type: "solid" },
12
11
  conditional_formats: [],
13
12
  aggregator: "avg"
14
13
  }.freeze
14
+ API_LIST_INCOMPLETE = false
15
15
 
16
16
  class ValidationError < RuntimeError
17
17
  end
18
18
 
19
+ settings :id, :kennel_id
20
+
19
21
  class << self
20
22
  private
21
23
 
@@ -56,6 +58,7 @@ module Kennel
56
58
  attr_reader :project
57
59
 
58
60
  def initialize(project, *args)
61
+ raise ArgumentError, "First argument must be a project, not #{project.class}" unless project.is_a?(Project)
59
62
  @project = project
60
63
  super(*args)
61
64
  end
@@ -3,23 +3,31 @@ module Kennel
3
3
  module Models
4
4
  class Slo < Record
5
5
  READONLY_ATTRIBUTES = superclass::READONLY_ATTRIBUTES + [:type_id, :monitor_tags]
6
- API_LIST_INCOMPLETE = false
7
6
  DEFAULTS = {
8
7
  description: nil,
9
8
  query: nil,
10
- monitor_ids: []
9
+ monitor_ids: [],
10
+ thresholds: []
11
11
  }.freeze
12
12
 
13
- settings :id, :type, :description, :thresholds, :query, :tags, :monitor_ids, :monitor_tags, :kennel_id, :name
13
+ settings :type, :description, :thresholds, :query, :tags, :monitor_ids, :monitor_tags, :name
14
14
 
15
15
  defaults(
16
16
  id: -> { nil },
17
17
  tags: -> { @project.tags },
18
18
  query: -> { DEFAULTS.fetch(:query) },
19
19
  description: -> { DEFAULTS.fetch(:description) },
20
- monitor_ids: -> { DEFAULTS.fetch(:monitor_ids) }
20
+ monitor_ids: -> { DEFAULTS.fetch(:monitor_ids) },
21
+ thresholds: -> { DEFAULTS.fetch(:thresholds) }
21
22
  )
22
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
+
23
31
  def as_json
24
32
  return @as_json if @as_json
25
33
  data = {
@@ -47,7 +55,7 @@ module Kennel
47
55
 
48
56
  def resolve_linked_tracking_ids(id_map)
49
57
  as_json[:monitor_ids] = as_json[:monitor_ids].map do |id|
50
- id.is_a?(String) ? resolve_link(id, id_map, force: true) : id
58
+ id.is_a?(String) ? resolve_link(id, id_map, force: false) || 1 : id
51
59
  end
52
60
  end
53
61
 
@@ -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? ["nodata:ignore"] }
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.57.0"
3
+ VERSION = "1.58.2"
4
4
  end
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.57.0
4
+ version: 1.58.2
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-12 00:00:00.000000000 Z
11
+ date: 2019-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday