dogapi-demo 0.1.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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.tailor +106 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +157 -0
- data/Gemfile +16 -0
- data/LICENSE +25 -0
- data/README.rdoc +143 -0
- data/Rakefile +50 -0
- data/dogapi-demo.gemspec +32 -0
- data/examples/Capfile +19 -0
- data/examples/custom_event.rb +37 -0
- data/examples/custom_metric.rb +35 -0
- data/lib/capistrano/README.md +13 -0
- data/lib/capistrano/datadog.rb +125 -0
- data/lib/capistrano/datadog/v2.rb +74 -0
- data/lib/capistrano/datadog/v3.rb +64 -0
- data/lib/dogapi-demo.rb +5 -0
- data/lib/dogapi-demo/common.rb +168 -0
- data/lib/dogapi-demo/event.rb +129 -0
- data/lib/dogapi-demo/facade.rb +475 -0
- data/lib/dogapi-demo/metric.rb +34 -0
- data/lib/dogapi-demo/v1.rb +13 -0
- data/lib/dogapi-demo/v1/alert.rb +112 -0
- data/lib/dogapi-demo/v1/comment.rb +62 -0
- data/lib/dogapi-demo/v1/dash.rb +94 -0
- data/lib/dogapi-demo/v1/embed.rb +106 -0
- data/lib/dogapi-demo/v1/event.rb +101 -0
- data/lib/dogapi-demo/v1/metric.rb +118 -0
- data/lib/dogapi-demo/v1/monitor.rb +264 -0
- data/lib/dogapi-demo/v1/screenboard.rb +110 -0
- data/lib/dogapi-demo/v1/search.rb +27 -0
- data/lib/dogapi-demo/v1/service_check.rb +32 -0
- data/lib/dogapi-demo/v1/snapshot.rb +30 -0
- data/lib/dogapi-demo/v1/tag.rb +141 -0
- data/lib/dogapi-demo/v1/user.rb +113 -0
- data/lib/dogapi-demo/version.rb +3 -0
- data/spec/alerts_spec.rb +33 -0
- data/spec/common_spec.rb +37 -0
- data/spec/facade_spec.rb +166 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/support/cassettes/Alerts/create/returns_HTTP_code_200.yml +114 -0
- data/spec/support/cassettes/Alerts/create/returns_a_valid_event_ID.yml +114 -0
- data/spec/support/cassettes/Alerts/create/returns_the_same_query_as_sent.yml +114 -0
- data/spec/support/cassettes/Facade/Events/emits_aggregate_events.yml +193 -0
- data/spec/support/cassettes/Facade/Events/emits_events_and_retrieves_them.yml +100 -0
- data/spec/support/cassettes/Facade/Events/emits_events_with_specified_priority.yml +98 -0
- data/spec/support/cassettes/Facade/Tags/adds_updates_and_detaches_tags.yml +442 -0
- data/tests/test_alerts.rb +38 -0
- data/tests/test_base.rb +30 -0
- data/tests/test_client.rb +23 -0
- data/tests/test_comments.rb +39 -0
- data/tests/test_dashes.rb +85 -0
- data/tests/test_embed.rb +194 -0
- data/tests/test_monitors.rb +192 -0
- data/tests/test_screenboard.rb +90 -0
- data/tests/test_search.rb +20 -0
- data/tests/test_snapshot.rb +28 -0
- data/tests/test_users.rb +65 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e504a22398729fed74aeafe8f837c5801a3955f0
|
4
|
+
data.tar.gz: e44e854e1101e22c0efc636bab841348f630cfb6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a04b7ed0c0cbbbfcbf2e1f2405ab70f664e8c7107425428fa81d2320a55ffc036c21d5cf7a430af480ae3679d1a58b9db327b04f21cdf7e7ba2fcb4a7475d04a
|
7
|
+
data.tar.gz: f4ecdf66407c69d31a59ed29432f4edb65ebfa8946e2ae071f234b629b0a2f8c3a9d2b0c410f729cb28813b82df3857a0ab549a29cb6022ea83e2affda119cc2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.tailor
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
#------------------------------------------------------------------------------
|
2
|
+
# Horizontal Whitespace
|
3
|
+
#------------------------------------------------------------------------------
|
4
|
+
# allow_hard_tabs True to let hard tabs be considered a single space.
|
5
|
+
# Default: false
|
6
|
+
#
|
7
|
+
# allow_trailing_line_spaces
|
8
|
+
# True to skip detecting extra spaces at the ends of
|
9
|
+
# lines.
|
10
|
+
# Default: false
|
11
|
+
#
|
12
|
+
# indentation_spaces The number of spaces to consider a proper indent.
|
13
|
+
# Default: 2
|
14
|
+
#
|
15
|
+
# max_line_length The maximum number of characters in a line before
|
16
|
+
# tailor complains.
|
17
|
+
# Default: 80
|
18
|
+
# spaces_after_comma Number of spaces to expect after a comma.
|
19
|
+
# Default: 1
|
20
|
+
#
|
21
|
+
# spaces_before_comma Number of spaces to expect before a comma.
|
22
|
+
# Default: 0
|
23
|
+
#
|
24
|
+
# spaces_after_lbrace The number of spaces to expect after an lbrace ('{').
|
25
|
+
# Default: 1
|
26
|
+
#
|
27
|
+
# spaces_before_lbrace The number of spaces to expect before an lbrace ('{').
|
28
|
+
# Default: 1
|
29
|
+
#
|
30
|
+
# spaces_before_rbrace The number of spaces to expect before an rbrace ('}').
|
31
|
+
# Default: 1
|
32
|
+
#
|
33
|
+
# spaces_in_empty_braces The number of spaces to expect between braces when
|
34
|
+
# there's nothing in the braces (i.e. {}).
|
35
|
+
# Default: 0
|
36
|
+
#
|
37
|
+
# spaces_after_lbracket The number of spaces to expect after an
|
38
|
+
# lbracket ('[').
|
39
|
+
# Default: 0
|
40
|
+
#
|
41
|
+
# spaces_before_rbracket The number of spaces to expect before an
|
42
|
+
# rbracket (']').
|
43
|
+
# Default: 0
|
44
|
+
#
|
45
|
+
# spaces_after_lparen The number of spaces to expect after an
|
46
|
+
# lparen ('(').
|
47
|
+
# Default: 0
|
48
|
+
#
|
49
|
+
# spaces_before_rparen The number of spaces to expect before an
|
50
|
+
# rbracket (')').
|
51
|
+
# Default: 0
|
52
|
+
#
|
53
|
+
#------------------------------------------------------------------------------
|
54
|
+
# Naming
|
55
|
+
#------------------------------------------------------------------------------
|
56
|
+
# allow_camel_case_methods
|
57
|
+
# Setting to true skips detection of camel-case method
|
58
|
+
# names (i.e. def myMethod).
|
59
|
+
# Default: false
|
60
|
+
#
|
61
|
+
# allow_screaming_snake_case_classes
|
62
|
+
# Setting to true skips detection of screaming
|
63
|
+
# snake-case class names (i.e. My_Class).
|
64
|
+
# Default: false
|
65
|
+
#
|
66
|
+
#------------------------------------------------------------------------------
|
67
|
+
# Vertical Whitespace
|
68
|
+
#------------------------------------------------------------------------------
|
69
|
+
# max_code_lines_in_class The number of lines of code in a class to allow before
|
70
|
+
# tailor will warn you.
|
71
|
+
# Default: 300
|
72
|
+
#
|
73
|
+
# max_code_lines_in_method
|
74
|
+
# The number of lines of code in a method to allow
|
75
|
+
# before tailor will warn you.
|
76
|
+
# Default: 30
|
77
|
+
#
|
78
|
+
# trailing_newlines The number of newlines that should be at the end of
|
79
|
+
# the file.
|
80
|
+
# Default: 1
|
81
|
+
#
|
82
|
+
Tailor.config do |config|
|
83
|
+
config.formatters "text"
|
84
|
+
config.file_set 'lib/**/*.rb' do |style|
|
85
|
+
style.allow_camel_case_methods false, level: :error
|
86
|
+
style.allow_hard_tabs false, level: :error
|
87
|
+
style.allow_screaming_snake_case_classes false, level: :error
|
88
|
+
style.allow_trailing_line_spaces false, level: :error
|
89
|
+
style.allow_invalid_ruby false, level: :warn
|
90
|
+
style.indentation_spaces 2, level: :error
|
91
|
+
style.max_code_lines_in_class 300, level: :error
|
92
|
+
style.max_code_lines_in_method 33, level: :error
|
93
|
+
style.max_line_length 160, level: :warn
|
94
|
+
style.spaces_after_comma 1, level: :error
|
95
|
+
style.spaces_after_lbrace 1, level: :error
|
96
|
+
style.spaces_after_lbracket 0, level: :error
|
97
|
+
style.spaces_after_lparen 0, level: :error
|
98
|
+
style.spaces_before_comma 0, level: :error
|
99
|
+
style.spaces_before_lbrace 1, level: :error
|
100
|
+
style.spaces_before_rbrace 1, level: :error
|
101
|
+
style.spaces_before_rbracket 0, level: :error
|
102
|
+
style.spaces_before_rparen 0, level: :error
|
103
|
+
style.spaces_in_empty_braces 0, level: :error
|
104
|
+
style.trailing_newlines 1, level: :error
|
105
|
+
end
|
106
|
+
end
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
Changes
|
2
|
+
=======
|
3
|
+
|
4
|
+
# 1.22.0 / 2016-04-14
|
5
|
+
* [FEATURE] Metric query API. See [#88][], [#90][] (thanks [@blakehilscher][])
|
6
|
+
|
7
|
+
# 1.21.0 / 2015-10-30
|
8
|
+
* [FEATURE] User CRUD API. See [#82][]
|
9
|
+
* [IMPROVEMENT] Support capistrano SimpleTextFormatter (thanks [@rmoriz][] [#81][])
|
10
|
+
|
11
|
+
# 1.20.0 / 2015-07-29
|
12
|
+
* [FEATURE] Embeddable graphs API. See [#73][]
|
13
|
+
|
14
|
+
# 1.19.0 / 2015-06-22
|
15
|
+
* [FEATURE] Revoke a shared a Screenboard. See [#69][]
|
16
|
+
|
17
|
+
# 1.18.0 / 2015-06-01
|
18
|
+
* [FEATURE] Add support for host muting.
|
19
|
+
|
20
|
+
# 1.17.0 / 2015-03-26
|
21
|
+
* [IMPROVEMENT] Use MultiJSON for JSON handling. (thanks [@winebarrel][] [#64][])
|
22
|
+
|
23
|
+
# 1.16.0 / 2015-03-06
|
24
|
+
* [IMPROVEMENT] Return response from API when metrics are sent as a batch. (thanks [@yyuu][] [#62](https://github.com/DataDog/dogapi-rb/pull/62))
|
25
|
+
|
26
|
+
# 1.15.0 / 2015-02-03
|
27
|
+
* [BUGFIX] Add open_timeout to avoid stuck HTTP calls (thanks [@Kaixiang][] [#55](https://github.com/DataDog/dogapi-rb/pull/55))
|
28
|
+
* [BUGFIX] Encode capistrano output messages to UTF-8 before manipulating them. (thanks [@byroot][] [#52](https://github.com/DataDog/dogapi-rb/pull/52))
|
29
|
+
|
30
|
+
# 1.14.0 / 2015-01-09
|
31
|
+
* [FEATURE] Add get_all_screenboards [#61](https://github.com/DataDog/dogapi-rb/pull/61)
|
32
|
+
* [IMPROVEMENT] Remove required start argument from schedule_downtime [#60](https://github.com/DataDog/dogapi-rb/pull/60)
|
33
|
+
|
34
|
+
# 1.13.0 / 2014-12-10
|
35
|
+
* [FEATURE] Add tag filter to get_all_monitors [#58](https://github.com/DataDog/dogapi-rb/pull/58)
|
36
|
+
* [FEATURE] Add update downtime method [#59](https://github.com/DataDog/dogapi-rb/pull/59)
|
37
|
+
|
38
|
+
# 1.12.0 / 2014-11-17
|
39
|
+
* [FEATURE] Add support for the Monitor API [#51](https://github.com/DataDog/dogapi-rb/pull/51)
|
40
|
+
* [IMPROVEMENT] Truncate event title and text before submission [#53](https://github.com/DataDog/dogapi-rb/pull/53)
|
41
|
+
|
42
|
+
# 1.11.0 / 2014-07-03
|
43
|
+
* [IMPROVEMENT] Add support for HTTP proxy defined by the environment variables
|
44
|
+
* [IMPROVEMENT] Allow to send several metrics in the same HTTP request
|
45
|
+
|
46
|
+
# 1.10.0 / 2014-05-13
|
47
|
+
* [IMPROVEMENT] Make HTTP timeout configurable ([#29](https://github.com/DataDog/dogapi-rb/issues/29))
|
48
|
+
* [IMPROVEMENT] Re-enable SSL verification ([#37](https://github.com/DataDog/dogapi-rb/issues/37))
|
49
|
+
* [IMPROVEMENT] Report application name when deploy with Capistrano (thanks [@ArjenSchwarz][] [#46](https://github.com/DataDog/dogapi-rb/pull/46))
|
50
|
+
|
51
|
+
# 1.9.2 / 2014-02-13
|
52
|
+
* [IMPROVEMENT] Fully support for capistrano v3 ([#43](https://github.com/DataDog/dogapi-rb/pull/43))
|
53
|
+
* [IMPROVEMENT] Strip control characters from capistrano messages ([#36](https://github.com/DataDog/dogapi-rb/issues/36))
|
54
|
+
* [IMPROVEMENT] Tag capistrano events by stage (thanks [@arielo][] [#25](https://github.com/DataDog/dogapi-rb/pull/25))
|
55
|
+
|
56
|
+
# 1.9.1 / 2014-01-06
|
57
|
+
* [IMPROVEMENT] Log a warning instead of crashing when trying to integration with capistrano v3
|
58
|
+
|
59
|
+
# 1.9.0 / 2013-09-06
|
60
|
+
* [IMPROVEMENT] When emitting a metric without an explicit host, default to local hostname.
|
61
|
+
|
62
|
+
# 1.8.1 / 2013-08-22
|
63
|
+
* [FEATURE] Update Dash API to support template variables.
|
64
|
+
|
65
|
+
# 1.8.0 / 2013-07-16
|
66
|
+
* [FEATURE] Add an API for interacting with Screenboards
|
67
|
+
|
68
|
+
# 1.7.1 / 2013-06-23
|
69
|
+
* [BUGFIX] Fix bug in capistrano integration with logging of nil (thanks [@arielo][])
|
70
|
+
* [FEATURE] Add an API for inviting users
|
71
|
+
* [FEATURE] Add an API for taking graph snapshots
|
72
|
+
|
73
|
+
# 1.7.0
|
74
|
+
* Not released.
|
75
|
+
|
76
|
+
# 1.6.0 / 2013-02-19
|
77
|
+
* [FEATURE] Support for setting `source` type when submitting host tags
|
78
|
+
|
79
|
+
# 1.5.2 / 2013-02-13
|
80
|
+
* [BUGFIX] Fix a bug in hashing the Event object when the instance variables are symbols.
|
81
|
+
|
82
|
+
# 1.5.0 / 2012-11-06
|
83
|
+
* [FEATURE] Alerting API
|
84
|
+
|
85
|
+
# 1.4.3
|
86
|
+
* [BUGFIX] Fix bug with capistrano integration for capistrano 2.13.5 (thanks [@ansel1][])
|
87
|
+
|
88
|
+
# 1.4.2
|
89
|
+
* [BUGFIX] Added missing dashboards endpoint.
|
90
|
+
|
91
|
+
# 1.4.1
|
92
|
+
* [BUGFIX] Fixed searching for events with tags.
|
93
|
+
|
94
|
+
# 1.4.0
|
95
|
+
* [FEATURE] Added support for the dashboard, search and comment API endpoints.
|
96
|
+
|
97
|
+
# 1.3.6
|
98
|
+
* [BUGFIX] Small fix for capistrano integration
|
99
|
+
|
100
|
+
# 1.3.4
|
101
|
+
* [BUGFIX] Various bug fixes (event.to_hash, md5 import, capistrano lambda roles)
|
102
|
+
|
103
|
+
# 1.3.3
|
104
|
+
* [BUGFIX] Bug fix for submitting counters
|
105
|
+
|
106
|
+
# 1.3.2
|
107
|
+
* [IMPROVEMENT] Support an aggregation key to aggregate events together
|
108
|
+
|
109
|
+
# 1.3.1
|
110
|
+
* [FEATURE] Metrics can be counters, rather than just gauges (thanks to [@treeder][])
|
111
|
+
* [FEATURE] Metrics can be tagged.
|
112
|
+
|
113
|
+
# 1.3.0
|
114
|
+
* [FEATURE] Capistrano integration. See https://github.com/DataDog/dogapi-rb/tree/master/lib/capistrano
|
115
|
+
|
116
|
+
# 1.2.x
|
117
|
+
* [FEATURE] You can now manage host tags
|
118
|
+
* [IMPROVEMENT] Functionality relating to events with a duration has been deprecated
|
119
|
+
* [IMPROVEMENT] The underlying clients have been updated to use Datadog's new public HTTP API[https://github.com/DataDog/dogapi/wiki]
|
120
|
+
* [IMPROVEMENT] You can now get event details and query the stream in addition to posting events
|
121
|
+
|
122
|
+
# 1.1.x
|
123
|
+
* [IMPROVEMENT] You do not need to use environment variables anymore to use the client.
|
124
|
+
|
125
|
+
<!--- The following link definition list is generated by PimpMyChangelog --->
|
126
|
+
[#25]: https://github.com/DataDog/dogapi-rb/issues/25
|
127
|
+
[#29]: https://github.com/DataDog/dogapi-rb/issues/29
|
128
|
+
[#36]: https://github.com/DataDog/dogapi-rb/issues/36
|
129
|
+
[#37]: https://github.com/DataDog/dogapi-rb/issues/37
|
130
|
+
[#43]: https://github.com/DataDog/dogapi-rb/issues/43
|
131
|
+
[#46]: https://github.com/DataDog/dogapi-rb/issues/46
|
132
|
+
[#51]: https://github.com/DataDog/dogapi-rb/issues/51
|
133
|
+
[#52]: https://github.com/DataDog/dogapi-rb/issues/52
|
134
|
+
[#53]: https://github.com/DataDog/dogapi-rb/issues/53
|
135
|
+
[#55]: https://github.com/DataDog/dogapi-rb/issues/55
|
136
|
+
[#58]: https://github.com/DataDog/dogapi-rb/issues/58
|
137
|
+
[#59]: https://github.com/DataDog/dogapi-rb/issues/59
|
138
|
+
[#60]: https://github.com/DataDog/dogapi-rb/issues/60
|
139
|
+
[#61]: https://github.com/DataDog/dogapi-rb/issues/61
|
140
|
+
[#62]: https://github.com/DataDog/dogapi-rb/issues/62
|
141
|
+
[#64]: https://github.com/DataDog/dogapi-rb/issues/64
|
142
|
+
[#69]: https://github.com/DataDog/dogapi-rb/issues/69
|
143
|
+
[#73]: https://github.com/DataDog/dogapi-rb/issues/73
|
144
|
+
[#81]: https://github.com/DataDog/dogapi-rb/issues/81
|
145
|
+
[#82]: https://github.com/DataDog/dogapi-rb/issues/82
|
146
|
+
[#88]: https://github.com/DataDog/dogapi-rb/issues/88
|
147
|
+
[#90]: https://github.com/DataDog/dogapi-rb/issues/90
|
148
|
+
[@ArjenSchwarz]: https://github.com/ArjenSchwarz
|
149
|
+
[@Kaixiang]: https://github.com/Kaixiang
|
150
|
+
[@ansel1]: https://github.com/ansel1
|
151
|
+
[@arielo]: https://github.com/arielo
|
152
|
+
[@blakehilscher]: https://github.com/blakehilscher
|
153
|
+
[@byroot]: https://github.com/byroot
|
154
|
+
[@rmoriz]: https://github.com/rmoriz
|
155
|
+
[@treeder]: https://github.com/treeder
|
156
|
+
[@winebarrel]: https://github.com/winebarrel
|
157
|
+
[@yyuu]: https://github.com/yyuu
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Copyright (c) 2011, Datadog <info@datadoghq.com>
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
* Neither the name of the Datadog nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL DATADOG BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
= Ruby Client for Datadog API
|
2
|
+
|
3
|
+
{<img src="https://badge.fury.io/rb/dogapi.png" alt="Gem Version" />}[http://badge.fury.io/rb/dogapi]
|
4
|
+
|
5
|
+
{<img src="https://travis-ci.org/DataDog/dogapi-rb.png?branch=master" alt="Build Status" />}[https://travis-ci.org/DataDog/dogapi-rb]
|
6
|
+
|
7
|
+
The Ruby client is a library suitable for inclusion in existing Ruby projects or for development of standalone scripts. It provides an abstraction on top of Datadog's raw HTTP interface for reporting events and metrics.
|
8
|
+
|
9
|
+
= What's new?
|
10
|
+
|
11
|
+
See CHANGELOG.md for details
|
12
|
+
|
13
|
+
= Installation
|
14
|
+
|
15
|
+
== From Source
|
16
|
+
|
17
|
+
Available at: https://github.com/DataDog/dogapi-rb
|
18
|
+
|
19
|
+
$ cd dogapi-rb
|
20
|
+
$ bundle
|
21
|
+
$ rake install
|
22
|
+
|
23
|
+
== Using RubyGems
|
24
|
+
|
25
|
+
Gem page: https://rubygems.org/gems/dogapi
|
26
|
+
|
27
|
+
$ gem install dogapi
|
28
|
+
|
29
|
+
If you get a permission error, you might need to run the install process with sudo:
|
30
|
+
|
31
|
+
$ sudo gem install dogapi
|
32
|
+
|
33
|
+
If you get a LoadError, missing mkmf, you need to install the development packages for ruby.
|
34
|
+
|
35
|
+
# on ubuntu e.g.
|
36
|
+
$ sudo apt-get install ruby-dev
|
37
|
+
|
38
|
+
= Usage
|
39
|
+
|
40
|
+
== How to find your API and application keys
|
41
|
+
|
42
|
+
Go to your setup page[https://app.datadoghq.com/account/settings].
|
43
|
+
|
44
|
+
== A word about hosts and devices
|
45
|
+
|
46
|
+
Events and metric data points can be attached to hosts
|
47
|
+
to take advantage of automatic tagging with the host's tags.
|
48
|
+
|
49
|
+
If you want to attach events and points to a specific device
|
50
|
+
on a host, simply specify the device when calling emit functions.
|
51
|
+
|
52
|
+
== Submit an event to Datadog
|
53
|
+
|
54
|
+
|
55
|
+
require 'rubygems'
|
56
|
+
require 'dogapi'
|
57
|
+
|
58
|
+
api_key = "abcdef123456"
|
59
|
+
|
60
|
+
# submitting events doesn't require an application_key, so we don't bother setting it
|
61
|
+
dog = Dogapi::Client.new(api_key)
|
62
|
+
|
63
|
+
dog.emit_event(Dogapi::Event.new('Testing done, FTW'), :host => "my_host")
|
64
|
+
|
65
|
+
|
66
|
+
== Tag a host in Datadog
|
67
|
+
|
68
|
+
|
69
|
+
require 'rubygems'
|
70
|
+
require 'dogapi'
|
71
|
+
|
72
|
+
api_key = "abcdef123456"
|
73
|
+
application_key = "fedcba654321"
|
74
|
+
|
75
|
+
dog = Dogapi::Client.new(api_key, application_key)
|
76
|
+
|
77
|
+
dog.add_tags("my_host", ["tagA", "tagB"])
|
78
|
+
|
79
|
+
|
80
|
+
== Submit a metric to Datadog
|
81
|
+
|
82
|
+
You want to track a new metric called +some+.+metric+.+name+ and have just sampled it from +my_device+ on +my_host+.
|
83
|
+
Its value is 50. Here is how you submit the value to Datadog.
|
84
|
+
|
85
|
+
|
86
|
+
require 'rubygems'
|
87
|
+
require 'dogapi'
|
88
|
+
|
89
|
+
api_key = "abcdef123456"
|
90
|
+
|
91
|
+
# submitting metrics doesn't require an application_key, so we don't bother setting it
|
92
|
+
dog = Dogapi::Client.new(api_key)
|
93
|
+
|
94
|
+
dog.emit_point('some.metric.name', 50.0, :host => "my_host", :device => "my_device")
|
95
|
+
|
96
|
+
|
97
|
+
Let us now assume that you have sampled the metric multiple times and you would like to submit the results.
|
98
|
+
You can use the +emit_points+ method (instead of +emit_point+). Since you are submitting more than one
|
99
|
+
data point you will need to pass a list of +Time+, +float+ pairs, instead of a simple +float+ value.
|
100
|
+
|
101
|
+
|
102
|
+
require 'rubygems'
|
103
|
+
require 'dogapi'
|
104
|
+
|
105
|
+
# Actual sampling takes place
|
106
|
+
t1 = Time.now
|
107
|
+
val1 = 50.0
|
108
|
+
|
109
|
+
# some time elapses
|
110
|
+
t2 = Time.now
|
111
|
+
val2 = 51.0
|
112
|
+
|
113
|
+
# some more time elapses
|
114
|
+
t3 = Time.now
|
115
|
+
val3 = -60.0
|
116
|
+
|
117
|
+
api_key = "abcdef123456"
|
118
|
+
|
119
|
+
dog = Dogapi::Client.new(api_key)
|
120
|
+
|
121
|
+
dog.emit_points('some.metric.name', [[t1, val1], [t2, val2], [t3, val3]], :host => "my_host", :device => "my_device")
|
122
|
+
|
123
|
+
|
124
|
+
== Get points from a Datadog metric
|
125
|
+
|
126
|
+
require 'rubygems'
|
127
|
+
require 'dogapi'
|
128
|
+
|
129
|
+
api_key = "abcd123"
|
130
|
+
application_key = "brec1252"
|
131
|
+
|
132
|
+
dog = Dogapi::Client.new(api_key, application_key)
|
133
|
+
|
134
|
+
# get points from the last hour
|
135
|
+
from = Time.now - 3600
|
136
|
+
to = Time.now
|
137
|
+
|
138
|
+
query = 'sum:metric.count{*}.as_count()'
|
139
|
+
|
140
|
+
dog.get_points(query, from, to)
|
141
|
+
|
142
|
+
|
143
|
+
|