dogapi 1.39.0 → 1.40.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/.rubocop_todo.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/Gemfile_1.9 +2 -0
- data/README.rdoc +7 -0
- data/dogapi.gemspec +2 -0
- data/lib/dogapi/common.rb +10 -0
- data/lib/dogapi/facade.rb +43 -0
- data/lib/dogapi/v1.rb +1 -0
- data/lib/dogapi/v1/service_level_objective.rb +113 -0
- data/lib/dogapi/version.rb +1 -1
- data/spec/integration/service_level_objective_spec.rb +73 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03dcbb8f50795fb901c13effb712107ac78beb545d55bebccb9f2cfc83c92908
|
|
4
|
+
data.tar.gz: d6cbb3c3dd0807d8d684879fa3efb44e8a54acd7c07298261ebc11b5b9a099e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b969abe11bd88812b9eb70066fb1d1fb2ff5df49a5a95de7c92893357dde80af0e5636500b1a7ed9703ce525a96d10662ff4900d09fd2676db263be17dfcaaf
|
|
7
|
+
data.tar.gz: 3b63c822096ba541151e837c16d47c0aa298baff22257be5b098e13041bba0dd00bba328d479240d17b2c58c9a1c9cacfdbf33a9416752b5a61a4dd65a999457
|
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 1.40.0 / 2020-04-06
|
|
4
|
+
|
|
5
|
+
* [Added] Re-add service level objectives support. See [#224](https://github.com/DataDog/dogapi-rb/pull/224).
|
|
6
|
+
|
|
3
7
|
## 1.39.0 / 2020-02-04
|
|
4
8
|
|
|
5
9
|
* [Added] Allow Setting Proxy without Using HTTP_PROXY, etc.. See [#180](https://github.com/DataDog/dogapi-rb/pull/180). Thanks [KingAlex42](https://github.com/KingAlex42).
|
data/Gemfile
CHANGED
|
@@ -4,6 +4,8 @@ gemspec
|
|
|
4
4
|
|
|
5
5
|
group :test do
|
|
6
6
|
gem 'rubocop', "~> 0.49.0"
|
|
7
|
+
# NOTE: rake < 12.3.3 is vulnerable to CVE-2020-8130, but we only use it as a test dependency
|
|
8
|
+
# and neither our users nor our CI is vulnerable in any way
|
|
7
9
|
gem 'rake', '>= 2.4.2'
|
|
8
10
|
gem 'rspec'
|
|
9
11
|
gem 'simplecov'
|
data/Gemfile_1.9
CHANGED
|
@@ -4,6 +4,8 @@ gemspec
|
|
|
4
4
|
|
|
5
5
|
group :test do
|
|
6
6
|
gem 'rubocop', "~> 0.41.0"
|
|
7
|
+
# NOTE: rake < 12.3.3 is vulnerable to CVE-2020-8130, but we only use it as a test dependency
|
|
8
|
+
# and neither our users nor our CI is vulnerable in any way
|
|
7
9
|
gem 'rake', '>= 2.4.2'
|
|
8
10
|
gem 'rspec'
|
|
9
11
|
gem 'simplecov', "~> 0.11.2"
|
data/README.rdoc
CHANGED
|
@@ -154,6 +154,13 @@ data point you will need to pass a list of +Time+, +float+ pairs, instead of a s
|
|
|
154
154
|
|
|
155
155
|
dog.emit_points('some.metric.name', [[t1, val1], [t2, val2], [t3, val3]], :host => "my_host", :device => "my_device")
|
|
156
156
|
|
|
157
|
+
If you want to specify the metric type, using the example above you can pass in a symbol key with :type and a value of a metric type such as counter, gauge or rate.
|
|
158
|
+
|
|
159
|
+
dog.emit_points('some.metric.name', [[t1, val1], [t2, val2], [t3, val3]], :host => "my_host", :device => "my_device", :type => 'counter' )
|
|
160
|
+
|
|
161
|
+
If you want to add metric tags, using the example above you can pass in a symbol key with :tags and an array of tags.
|
|
162
|
+
|
|
163
|
+
dog.emit_points('some.metric.name', [[t1, val1], [t2, val2], [t3, val3]], :host => "my_host", :device => "my_device", :tags => ['frontend', 'app:webserver'] )
|
|
157
164
|
|
|
158
165
|
== Get points from a Datadog metric
|
|
159
166
|
|
data/dogapi.gemspec
CHANGED
|
@@ -33,6 +33,8 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
spec.add_dependency 'multi_json'
|
|
34
34
|
|
|
35
35
|
spec.add_development_dependency 'bundler', '>= 1.3'
|
|
36
|
+
# NOTE: rake < 12.3.3 is vulnerable to CVE-2020-8130, but we only use it as a test dependency
|
|
37
|
+
# and neither our users nor our CI is vulnerable in any way
|
|
36
38
|
spec.add_development_dependency 'rake', '~> 10'
|
|
37
39
|
spec.add_development_dependency 'rdoc'
|
|
38
40
|
end
|
data/lib/dogapi/common.rb
CHANGED
|
@@ -224,4 +224,14 @@ module Dogapi
|
|
|
224
224
|
raise ArgumentError, "Each tag needs to be a string. Current value: #{tag}" unless tag.is_a? String
|
|
225
225
|
end
|
|
226
226
|
end
|
|
227
|
+
|
|
228
|
+
# Very simplified hash with indifferent access - access to string or symbol
|
|
229
|
+
# keys via symbols. E.g.:
|
|
230
|
+
# my_hash = { 'foo' => 1 }
|
|
231
|
+
# Dogapi.symbolized_access(my_hash)
|
|
232
|
+
# my_hash[:foo] # => 1
|
|
233
|
+
def Dogapi.symbolized_access(hash)
|
|
234
|
+
hash.default_proc = proc { |h, k| h.key?(k.to_s) ? h[k.to_s] : nil }
|
|
235
|
+
hash
|
|
236
|
+
end
|
|
227
237
|
end
|
data/lib/dogapi/facade.rb
CHANGED
|
@@ -105,6 +105,9 @@ module Dogapi
|
|
|
105
105
|
@usage_svc = Dogapi::V1::UsageService.new(@api_key, @application_key, silent, timeout, @datadog_host)
|
|
106
106
|
@azure_integration_svc = Dogapi::V1::AzureIntegrationService.new(@api_key, @application_key, silent, timeout, @datadog_host)
|
|
107
107
|
@gcp_integration_svc = Dogapi::V1::GcpIntegrationService.new(@api_key, @application_key, silent, timeout, @datadog_host)
|
|
108
|
+
@service_level_objective_svc = Dogapi::V1::ServiceLevelObjectiveService.new(@api_key, @application_key, silent,
|
|
109
|
+
timeout, @datadog_host)
|
|
110
|
+
|
|
108
111
|
# Support for Dashboard List API v2.
|
|
109
112
|
@v2 = Dogapi::ClientV2.new(@api_key, @application_key, true, true, @datadog_host)
|
|
110
113
|
|
|
@@ -673,6 +676,46 @@ module Dogapi
|
|
|
673
676
|
@monitor_svc.unmute_host(hostname)
|
|
674
677
|
end
|
|
675
678
|
|
|
679
|
+
#
|
|
680
|
+
# SERVICE LEVEL OBJECTIVES
|
|
681
|
+
#
|
|
682
|
+
|
|
683
|
+
def create_service_level_objective(type, slo_name, thresholds, options = {})
|
|
684
|
+
@service_level_objective_svc.create_service_level_objective(type, slo_name, thresholds, options)
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
def update_service_level_objective(slo_id, type, options = {})
|
|
688
|
+
@service_level_objective_svc.update_service_level_objective(slo_id, type, options)
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
def get_service_level_objective(slo_id)
|
|
692
|
+
@service_level_objective_svc.get_service_level_objective(slo_id)
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
def get_service_level_objective_history(slo_id, from_ts, to_ts)
|
|
696
|
+
@service_level_objective_svc.get_service_level_objective_history(slo_id, from_ts, to_ts)
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
def search_service_level_objective(slo_ids = nil, query = nil, offset = nil, limit = nil)
|
|
700
|
+
@service_level_objective_svc.search_service_level_objective(slo_ids, query, offset, limit)
|
|
701
|
+
end
|
|
702
|
+
|
|
703
|
+
def can_delete_service_level_objective(slo_ids)
|
|
704
|
+
@service_level_objective_svc.can_delete_service_level_objective(slo_ids)
|
|
705
|
+
end
|
|
706
|
+
|
|
707
|
+
def delete_service_level_objective(slo_id)
|
|
708
|
+
@service_level_objective_svc.delete_service_level_objective(slo_id)
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
def delete_many_service_level_objective(slo_ids)
|
|
712
|
+
@service_level_objective_svc.delete_many_service_level_objective(slo_ids)
|
|
713
|
+
end
|
|
714
|
+
|
|
715
|
+
def delete_timeframes_service_level_objective(ops)
|
|
716
|
+
@service_level_objective_svc.delete_timeframes_service_level_objective(ops)
|
|
717
|
+
end
|
|
718
|
+
|
|
676
719
|
#
|
|
677
720
|
# SERVICE CHECKS
|
|
678
721
|
#
|
data/lib/dogapi/v1.rb
CHANGED
|
@@ -15,6 +15,7 @@ require 'dogapi/v1/monitor'
|
|
|
15
15
|
require 'dogapi/v1/screenboard'
|
|
16
16
|
require 'dogapi/v1/search'
|
|
17
17
|
require 'dogapi/v1/service_check'
|
|
18
|
+
require 'dogapi/v1/service_level_objective'
|
|
18
19
|
require 'dogapi/v1/snapshot'
|
|
19
20
|
require 'dogapi/v1/synthetics'
|
|
20
21
|
require 'dogapi/v1/tag'
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require 'dogapi'
|
|
2
|
+
|
|
3
|
+
module Dogapi
|
|
4
|
+
class V1 # for namespacing
|
|
5
|
+
|
|
6
|
+
# Implements Service Level Objectives endpoints
|
|
7
|
+
class ServiceLevelObjectiveService < Dogapi::APIService
|
|
8
|
+
|
|
9
|
+
API_VERSION = 'v1'
|
|
10
|
+
|
|
11
|
+
def create_service_level_objective(type, slo_name, thresholds, options = {})
|
|
12
|
+
body = {
|
|
13
|
+
type: type,
|
|
14
|
+
name: slo_name,
|
|
15
|
+
thresholds: thresholds
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
symbolized_options = Dogapi.symbolized_access(options)
|
|
19
|
+
if type.to_s == 'metric'
|
|
20
|
+
body[:query] = {
|
|
21
|
+
numerator: symbolized_options[:numerator],
|
|
22
|
+
denominator: symbolized_options[:denominator]
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
body[:monitor_search] = symbolized_options[:monitor_search] if symbolized_options[:monitor_search]
|
|
26
|
+
body[:monitor_ids] = symbolized_options[:monitor_ids] if symbolized_options[:monitor_ids]
|
|
27
|
+
body[:groups] = symbolized_options[:groups] if symbolized_options[:groups]
|
|
28
|
+
end
|
|
29
|
+
body[:tags] = symbolized_options[:tags] if symbolized_options[:tags]
|
|
30
|
+
body[:description] = symbolized_options[:description] if symbolized_options[:description]
|
|
31
|
+
|
|
32
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/slo", nil, body, true)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def update_service_level_objective(slo_id, type, options = {})
|
|
36
|
+
body = {
|
|
37
|
+
type: type
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
symbolized_options = Dogapi.symbolized_access(options)
|
|
41
|
+
if type == 'metric'
|
|
42
|
+
if symbolized_options[:numerator] && symbolized_options[:denominator]
|
|
43
|
+
body[:query] = {
|
|
44
|
+
numerator: symbolized_options[:numerator],
|
|
45
|
+
denominator: symbolized_options[:denominator]
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
body[:monitor_search] = symbolized_options[:monitor_search] if symbolized_options[:monitor_search]
|
|
50
|
+
body[:monitor_ids] = symbolized_options[:monitor_ids] if symbolized_options[:monitor_ids]
|
|
51
|
+
body[:groups] = symbolized_options[:groups] if symbolized_options[:groups]
|
|
52
|
+
end
|
|
53
|
+
[:name, :thresholds, :tags, :description].each do |a|
|
|
54
|
+
body[a] = symbolized_options[a] if symbolized_options[a]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
request(Net::HTTP::Put, "/api/#{API_VERSION}/slo/#{slo_id}", nil, body, true)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def get_service_level_objective(slo_id)
|
|
61
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/slo/#{slo_id}", nil, nil, false)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def search_service_level_objective(slo_ids, query, offset, limit)
|
|
65
|
+
params = {}
|
|
66
|
+
params[:offset] = offset unless offset.nil?
|
|
67
|
+
params[:limit] = limit unless limit.nil?
|
|
68
|
+
if !slo_ids.nil?
|
|
69
|
+
params[:ids] = slo_ids.join(',')
|
|
70
|
+
else
|
|
71
|
+
params[:query] = query
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/slo/", params, nil, false)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def delete_service_level_objective(slo_id)
|
|
78
|
+
request(Net::HTTP::Delete, "/api/#{API_VERSION}/slo/#{slo_id}", nil, nil, false)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def delete_many_service_level_objective(slo_ids)
|
|
82
|
+
body = {
|
|
83
|
+
ids: slo_ids
|
|
84
|
+
}
|
|
85
|
+
request(Net::HTTP::Delete, "/api/#{API_VERSION}/slo/", nil, body, true)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def delete_timeframes_service_level_objective(ops)
|
|
89
|
+
# ops is a hash of slo_id: [<timeframe>] to delete
|
|
90
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/slo/bulk_delete", nil, ops, true)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def get_service_level_objective_history(slo_id, from_ts, to_ts)
|
|
94
|
+
params = {
|
|
95
|
+
from_ts: from_ts,
|
|
96
|
+
to_ts: to_ts
|
|
97
|
+
}
|
|
98
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/slo/#{slo_id}/history", params, nil, false)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def can_delete_service_level_objective(slo_ids)
|
|
102
|
+
params = {}
|
|
103
|
+
params[:ids] = if slo_ids.is_a? Array
|
|
104
|
+
slo_ids.join(',')
|
|
105
|
+
else
|
|
106
|
+
slo_ids
|
|
107
|
+
end
|
|
108
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/slo/can_delete", params, nil, false)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
data/lib/dogapi/version.rb
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require_relative '../spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Dogapi::Client do
|
|
4
|
+
SLO_ID = '42424242424242424242424242424242'.freeze
|
|
5
|
+
SLO_TYPE = 'metric'.freeze
|
|
6
|
+
SLO_NAME = 'test slo'.freeze
|
|
7
|
+
SLO_DESCRIPTION = 'test slo description'.freeze
|
|
8
|
+
SLO_QUERY_NUMERATOR = 'sum:test.metric.metric{type:good}.as_count()'.freeze
|
|
9
|
+
SLO_QUERY_DENOMINATOR = 'sum:test.metric.metric{*}.as_count()'.freeze
|
|
10
|
+
SLO_TAGS = ['type:test'].freeze
|
|
11
|
+
SLO_THRESHOLDS = [{ timeframe: '7d', target: 90 }, { timeframe: '30d', target: 95 }].freeze
|
|
12
|
+
|
|
13
|
+
describe '#create_service_level_objective' do
|
|
14
|
+
it_behaves_like 'an api method',
|
|
15
|
+
:create_service_level_objective, [SLO_TYPE, SLO_NAME, SLO_THRESHOLDS, {
|
|
16
|
+
description: SLO_DESCRIPTION,
|
|
17
|
+
tags: SLO_TAGS,
|
|
18
|
+
numerator: SLO_QUERY_NUMERATOR,
|
|
19
|
+
denominator: SLO_QUERY_DENOMINATOR
|
|
20
|
+
}],
|
|
21
|
+
:post, '/slo', 'type' => SLO_TYPE, 'name' => SLO_NAME, 'thresholds' => SLO_THRESHOLDS,
|
|
22
|
+
'query' => { numerator: SLO_QUERY_NUMERATOR, denominator: SLO_QUERY_DENOMINATOR },
|
|
23
|
+
'tags' => SLO_TAGS, 'description' => SLO_DESCRIPTION
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe '#update_service_level_objective' do
|
|
27
|
+
it_behaves_like 'an api method',
|
|
28
|
+
:update_service_level_objective, [SLO_ID, SLO_TYPE, { name: SLO_NAME }],
|
|
29
|
+
:put, "/slo/#{SLO_ID}", 'type' => SLO_TYPE, 'name' => SLO_NAME
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '#get_service_level_objective' do
|
|
33
|
+
it_behaves_like 'an api method',
|
|
34
|
+
:get_service_level_objective, [SLO_ID],
|
|
35
|
+
:get, "/slo/#{SLO_ID}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '#get_service_level_objective_history' do
|
|
39
|
+
it_behaves_like 'an api method with params',
|
|
40
|
+
:get_service_level_objective_history, [SLO_ID],
|
|
41
|
+
:get, "/slo/#{SLO_ID}/history", 'from_ts' => 0, 'to_ts' => 1_000_000
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '#can_delete_service_level_objective' do
|
|
45
|
+
it_behaves_like 'an api method with params',
|
|
46
|
+
:can_delete_service_level_objective, [],
|
|
47
|
+
:get, '/slo/can_delete', 'ids' => [SLO_ID]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#search_service_level_objective' do
|
|
51
|
+
it_behaves_like 'an api method with optional params',
|
|
52
|
+
:search_service_level_objective, [[SLO_ID]],
|
|
53
|
+
:get, '/slo/', 'ids' => SLO_ID
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe '#delete_service_level_objective' do
|
|
57
|
+
it_behaves_like 'an api method',
|
|
58
|
+
:delete_service_level_objective, [SLO_ID],
|
|
59
|
+
:delete, "/slo/#{SLO_ID}"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe '#delete_many_service_level_objective' do
|
|
63
|
+
it_behaves_like 'an api method',
|
|
64
|
+
:delete_many_service_level_objective, [[SLO_ID]],
|
|
65
|
+
:delete, '/slo/', 'ids' => [SLO_ID]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#delete_timeframes_service_level_objective' do
|
|
69
|
+
it_behaves_like 'an api method',
|
|
70
|
+
:delete_timeframes_service_level_objective, [{ SLO_ID => ['7d'] }],
|
|
71
|
+
:post, '/slo/bulk_delete', SLO_ID => ['7d']
|
|
72
|
+
end
|
|
73
|
+
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.40.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: 2020-
|
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: multi_json
|
|
@@ -131,6 +131,7 @@ files:
|
|
|
131
131
|
- lib/dogapi/v1/screenboard.rb
|
|
132
132
|
- lib/dogapi/v1/search.rb
|
|
133
133
|
- lib/dogapi/v1/service_check.rb
|
|
134
|
+
- lib/dogapi/v1/service_level_objective.rb
|
|
134
135
|
- lib/dogapi/v1/snapshot.rb
|
|
135
136
|
- lib/dogapi/v1/synthetics.rb
|
|
136
137
|
- lib/dogapi/v1/tag.rb
|
|
@@ -158,6 +159,7 @@ files:
|
|
|
158
159
|
- spec/integration/screenboard_spec.rb
|
|
159
160
|
- spec/integration/search_spec.rb
|
|
160
161
|
- spec/integration/service_check_spec.rb
|
|
162
|
+
- spec/integration/service_level_objective_spec.rb
|
|
161
163
|
- spec/integration/snapshot_spec.rb
|
|
162
164
|
- spec/integration/synthetics_spec.rb
|
|
163
165
|
- spec/integration/tag_spec.rb
|
|
@@ -220,6 +222,7 @@ test_files:
|
|
|
220
222
|
- spec/integration/screenboard_spec.rb
|
|
221
223
|
- spec/integration/search_spec.rb
|
|
222
224
|
- spec/integration/service_check_spec.rb
|
|
225
|
+
- spec/integration/service_level_objective_spec.rb
|
|
223
226
|
- spec/integration/snapshot_spec.rb
|
|
224
227
|
- spec/integration/synthetics_spec.rb
|
|
225
228
|
- spec/integration/tag_spec.rb
|