dogapi 1.12.0 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/dogapi/facade.rb +4 -0
- data/lib/dogapi/v1/monitor.rb +24 -6
- data/lib/dogapi/version.rb +1 -1
- data/tests/test_alerts.rb +2 -2
- data/tests/test_monitors.rb +20 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 956ac3cdbbcc21917fe835e1857513ed612f1b70
|
4
|
+
data.tar.gz: 8c1a5434a0aa26ffe0dfa6bd14c6e40950699300
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fca5bb8a66a263e41d1987ffeb9a2481cece0baafb78a8e9ef1e7247b8dca666a4088273a44e6182b7223d511d970a1a1c00e321a518983d75b88db0d7f2662e
|
7
|
+
data.tar.gz: 4f7475ae3fbcba75d0acf61ff74bb26b5c1fd13edf7a9786b9bd82bf862d0c187f50c65ab86849defff97cfce7f5a5abf457afdfba4db68b47c6ac62756c4ee3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
Changes
|
2
2
|
=======
|
3
|
+
# 1.13.0 / 2014-12-10
|
4
|
+
* Add tag filter to get_all_monitors [#58](https://github.com/DataDog/dogapi-rb/pull/58)
|
5
|
+
* Add update downtime method [#59](https://github.com/DataDog/dogapi-rb/pull/59)
|
6
|
+
|
3
7
|
# 1.12.0 / 2014-11-17
|
4
8
|
* Add support for the Monitor API [#51](https://github.com/DataDog/dogapi-rb/pull/51)
|
5
9
|
* Truncate event title and text before submission [#53](https://github.com/DataDog/dogapi-rb/pull/53)
|
data/lib/dogapi/facade.rb
CHANGED
@@ -366,6 +366,10 @@ module Dogapi
|
|
366
366
|
@monitor_svc.schedule_downtime(scope, start, options)
|
367
367
|
end
|
368
368
|
|
369
|
+
def update_downtime(downtime_id, options = {})
|
370
|
+
@monitor_svc.update_downtime(downtime_id, options)
|
371
|
+
end
|
372
|
+
|
369
373
|
def get_downtime(downtime_id)
|
370
374
|
@monitor_svc.get_downtime(downtime_id)
|
371
375
|
end
|
data/lib/dogapi/v1/monitor.rb
CHANGED
@@ -52,10 +52,7 @@ module Dogapi
|
|
52
52
|
# :group_states is an optional list of statuses to filter returned
|
53
53
|
# groups. If no value is given then no group states will be returned.
|
54
54
|
# Possible values are: "all", "ok", "warn", "alert", "no data".
|
55
|
-
if options[:group_states]
|
56
|
-
params[:group_states] = options[:group_states].join(',')
|
57
|
-
options.delete :group_states
|
58
|
-
end
|
55
|
+
params[:group_states] = options[:group_states].join(',') if options[:group_states]
|
59
56
|
|
60
57
|
request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor/#{monitor_id}", params, nil, false)
|
61
58
|
rescue Exception => e
|
@@ -87,8 +84,16 @@ module Dogapi
|
|
87
84
|
# groups. If no value is given then no group states will be returned.
|
88
85
|
# Possible values are: "all", "ok", "warn", "alert", "no data".
|
89
86
|
if options[:group_states]
|
90
|
-
params[:group_states] = options[:group_states]
|
91
|
-
|
87
|
+
params[:group_states] = options[:group_states]
|
88
|
+
params[:group_states] = params[:group_states].join(',') if params[:group_states].respond_to?(:join)
|
89
|
+
end
|
90
|
+
|
91
|
+
# :tags is an optional list of scope tags to filter the list of monitors
|
92
|
+
# returned. If no value is given, then all monitors, regardless of
|
93
|
+
# scope, will be returned.
|
94
|
+
if options[:tags]
|
95
|
+
params[:tags] = options[:tags]
|
96
|
+
params[:tags] = params[:tags].join(',') if params[:tags].respond_to?(:join)
|
92
97
|
end
|
93
98
|
|
94
99
|
request(Net::HTTP::Get, "/api/#{API_VERSION}/monitor", params, nil, false)
|
@@ -170,6 +175,19 @@ module Dogapi
|
|
170
175
|
end
|
171
176
|
end
|
172
177
|
|
178
|
+
def update_downtime(downtime_id, options = {})
|
179
|
+
begin
|
180
|
+
params = {
|
181
|
+
:api_key => @api_key,
|
182
|
+
:application_key => @application_key
|
183
|
+
}
|
184
|
+
|
185
|
+
request(Net::HTTP::Put, "/api/#{API_VERSION}/downtime/#{downtime_id}", params, options, true)
|
186
|
+
rescue Exception => e
|
187
|
+
suppress_error_if_silent e
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
173
191
|
def get_downtime(downtime_id)
|
174
192
|
begin
|
175
193
|
params = {
|
data/lib/dogapi/version.rb
CHANGED
data/tests/test_alerts.rb
CHANGED
@@ -13,12 +13,12 @@ class TestAlerts < Test::Unit::TestCase
|
|
13
13
|
alert_id = dog.alert(query)[1]['id']
|
14
14
|
status, alert = dog.get_alert(alert_id)
|
15
15
|
assert_equal alert['query'], query, alert['query']
|
16
|
-
assert_equal alert['silenced'],
|
16
|
+
assert_equal alert['silenced'], false, alert['silenced']
|
17
17
|
|
18
18
|
dog.update_alert(alert_id, query, :silenced => true)
|
19
19
|
status, alert = dog.get_alert(alert_id)
|
20
20
|
assert_equal alert['query'], query, alert['query']
|
21
|
-
assert_equal alert['silenced'],
|
21
|
+
assert_equal alert['silenced'], true, alert['silenced']
|
22
22
|
|
23
23
|
dog.delete_alert(alert_id)
|
24
24
|
|
data/tests/test_monitors.rb
CHANGED
@@ -38,17 +38,26 @@ class TestAlerts < Test::Unit::TestCase
|
|
38
38
|
|
39
39
|
query1 = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 100"
|
40
40
|
query2 = "avg(last_1h):sum:system.net.bytes_rcvd{host:host0} > 200"
|
41
|
+
query3 = "avg(last_1h):sum:system.net.bytes_rcvd{host:host1} > 200"
|
41
42
|
|
42
43
|
monitor_id1 = dog.monitor('metric alert', query1)[1]['id']
|
43
44
|
monitor_id2 = dog.monitor('metric alert', query2)[1]['id']
|
45
|
+
monitor_id3 = dog.monitor('metric alert', query3)[1]['id']
|
44
46
|
status, monitors = dog.get_all_monitors(:group_states => ['alert', 'warn'])
|
45
47
|
monitor1 = monitors.map{|m| m if m['id'] == monitor_id1}.compact[0]
|
46
48
|
monitor2 = monitors.map{|m| m if m['id'] == monitor_id2}.compact[0]
|
47
49
|
assert_equal monitor1['query'], query1, monitor1['query']
|
48
50
|
assert_equal monitor2['query'], query2, monitor2['query']
|
49
51
|
|
52
|
+
status, monitors = dog.get_all_monitors(:tags => ['host:host1'])
|
53
|
+
monitor3 = monitors.map{|m| m if m['id'] == monitor_id3}.compact[0]
|
54
|
+
assert_equal monitor3['query'], query3, monitor3['query']
|
55
|
+
assert_equal nil, monitors.map{|m| m if m['id'] == monitor_id1}.compact[0]
|
56
|
+
assert_equal nil, monitors.map{|m| m if m['id'] == monitor_id2}.compact[0]
|
57
|
+
|
50
58
|
dog.delete_monitor(monitor_id1)
|
51
59
|
dog.delete_monitor(monitor_id2)
|
60
|
+
dog.delete_monitor(monitor_id3)
|
52
61
|
end
|
53
62
|
|
54
63
|
def test_checks
|
@@ -120,11 +129,21 @@ class TestAlerts < Test::Unit::TestCase
|
|
120
129
|
dog = Dogapi::Client.new(@api_key, @app_key)
|
121
130
|
start_ts = Time.now.to_i
|
122
131
|
end_ts = start_ts + 1000
|
123
|
-
downtime_id = dog.schedule_downtime('env:staging', start_ts, :end => end_ts
|
132
|
+
downtime_id = dog.schedule_downtime('env:staging', start_ts, :end => end_ts,
|
133
|
+
:message=>'Message!')[1]['id']
|
124
134
|
status, dt = dog.get_downtime(downtime_id)
|
125
135
|
assert_equal dt['start'], start_ts, dt['start']
|
126
136
|
assert_equal dt['end'], end_ts, dt['end']
|
127
137
|
assert_equal dt['scope'], ['env:staging'], dt['scope']
|
138
|
+
assert_equal dt['message'], 'Message!', dt['messsage']
|
139
|
+
|
140
|
+
dog.update_downtime(downtime_id, :start => start_ts + 1, :end => end_ts + 1,
|
141
|
+
:scope => 'env:prod', :message => 'New Message!')
|
142
|
+
status, dt = dog.get_downtime(downtime_id)
|
143
|
+
assert_equal dt['start'], start_ts + 1, dt['start']
|
144
|
+
assert_equal dt['end'], end_ts + 1, dt['end']
|
145
|
+
assert_equal dt['scope'], ['env:prod'], dt['scope']
|
146
|
+
assert_equal dt['message'], 'New Message!', dt['messsage']
|
128
147
|
|
129
148
|
dog.cancel_downtime(downtime_id)
|
130
149
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dogapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|