lita-datadog 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 +18 -0
- data/.rubocop.yml +9 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/lib/lita-datadog.rb +7 -0
- data/lib/lita/handlers/datadog.rb +48 -0
- data/lita-datadog.gemspec +25 -0
- data/locales/en.yml +4 -0
- data/spec/lita/handlers/datadog_spec.rb +37 -0
- data/spec/spec_helper.rb +10 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d792f049f2c903792f8cb120c287e363c3f7db64
|
4
|
+
data.tar.gz: 2b2be86036fbd45be1d6790e952ecfb943be5ed3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8284cb8a9a066aecfe14f0a48aefc90a803fffb3a168cd191939cc9874327322df3a12a6e917def236ce1918e99910565d83de412350fa6ed0663995314f3e1e
|
7
|
+
data.tar.gz: f3443b1b0f27fce7981a533706641f58ac6f67048dd12765c7d5d32201747fae1c790280e0880eca20cc8e7fea8431739eac4186f16beab7f0b22f6f0a225f0d
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Eric Sigler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# lita-datadog
|
2
|
+
|
3
|
+
[](https://travis-ci.org/esigler/lita-datadog)
|
4
|
+
[](https://codeclimate.com/github/esigler/lita-datadog)
|
5
|
+
[](https://coveralls.io/r/esigler/lita-datadog)
|
6
|
+
|
7
|
+
Interact with Datadog (https://www.datadoghq.com/).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add lita-datadog to your Lita instance's Gemfile:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem "lita-datadog"
|
15
|
+
```
|
16
|
+
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
### Required attributes
|
20
|
+
|
21
|
+
You will need to get your API key, and configure an application key. Go to https://app.datadoghq.com/account/settings#api for both.
|
22
|
+
|
23
|
+
* `api_key` (String) - Your DataDog API key. Default: `nil`
|
24
|
+
* `application_key` (String) - Your DataDog application key. Default: `nil`
|
25
|
+
|
26
|
+
### Optional attributes
|
27
|
+
|
28
|
+
* `default_timerange` (Integer) - How long in seconds a default time range will be for graphs. Default: `3600`
|
29
|
+
|
30
|
+
### Example
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
```
|
35
|
+
Lita graph metric:"system.load.1{*}"
|
36
|
+
Lita graph metric:"system.load.1{*},system.load.5{*}"
|
37
|
+
```
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
data/lib/lita-datadog.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'dogapi'
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class Datadog < Handler
|
6
|
+
route(
|
7
|
+
/^graph\smetric:"(\S+)"$/,
|
8
|
+
:simple_metric,
|
9
|
+
command: true,
|
10
|
+
help: { 'graph metric:"simple.metric.1{*},simple.metric.5{*}"' =>
|
11
|
+
'Graph those metrics across all events, for the default time range' }
|
12
|
+
)
|
13
|
+
|
14
|
+
def self.default_config(config)
|
15
|
+
config.api_key = nil
|
16
|
+
config.application_key = nil
|
17
|
+
config.default_timerange = 3600
|
18
|
+
end
|
19
|
+
|
20
|
+
def simple_metric(response)
|
21
|
+
metric = response.matches[0][0]
|
22
|
+
end_ts = Time.now.to_i
|
23
|
+
start_ts = end_ts - Lita.config.handlers.datadog.default_timerange
|
24
|
+
_return_code, snapshot = graph_snapshot(metric, start_ts, end_ts, '*')
|
25
|
+
if snapshot
|
26
|
+
sleep 1 # TODO: Requesting the image immediately causes a blank image to be cached.
|
27
|
+
response.reply(snapshot['snapshot_url'])
|
28
|
+
else
|
29
|
+
response.reply('Error requesting Datadog graph')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def graph_snapshot(metric_query, start_ts, end_ts, event_query)
|
36
|
+
return nil if Lita.config.handlers.datadog.api_key.nil? ||
|
37
|
+
Lita.config.handlers.datadog.application_key.nil?
|
38
|
+
|
39
|
+
client = Dogapi::Client.new(Lita.config.handlers.datadog.api_key,
|
40
|
+
Lita.config.handlers.datadog.application_key)
|
41
|
+
|
42
|
+
return client.graph_snapshot(metric_query, start_ts, end_ts, event_query) if client
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Lita.register_handler(Datadog)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-datadog"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Eric Sigler"]
|
5
|
+
spec.email = ["me@esigler.com"]
|
6
|
+
spec.description = %q{A Lita handler for interacting with Datadog}
|
7
|
+
spec.summary = %q{Query metrics, events, and generate graphs from Datadog}
|
8
|
+
spec.homepage = "http://github.com/esigler/lita-datadog"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 3.0"
|
18
|
+
spec.add_runtime_dependency "dogapi"
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
|
23
|
+
spec.add_development_dependency "simplecov"
|
24
|
+
spec.add_development_dependency "coveralls"
|
25
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Lita::Handlers::Datadog, lita_handler: true do
|
4
|
+
it { routes_command('graph metric:"system.load.1{*}"').to(:simple_metric) }
|
5
|
+
it { routes_command('graph metric:"system.load.1{*},system.load.5{*}"').to(:simple_metric) }
|
6
|
+
|
7
|
+
describe '.default_config' do
|
8
|
+
it 'sets the api_key to nil' do
|
9
|
+
expect(Lita.config.handlers.datadog.api_key).to be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'sets the application_key to nil' do
|
13
|
+
expect(Lita.config.handlers.datadog.application_key).to be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'sets the default_timerange to 3600' do
|
17
|
+
expect(Lita.config.handlers.datadog.default_timerange).to eq(3600)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#simple_metric' do
|
22
|
+
it 'with valid metric returns an image url' do
|
23
|
+
response = { 'snapshot_url' => 'http://www.example.com/path/that/ends/in.png' }
|
24
|
+
allow_any_instance_of(Lita::Handlers::Datadog).to \
|
25
|
+
receive(:graph_snapshot).with(any_args).and_return([200, response])
|
26
|
+
send_command('graph metric:"system.load.1{*}"')
|
27
|
+
expect(replies.last).to eq('http://www.example.com/path/that/ends/in.png')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'with invalid metric returns an error' do
|
31
|
+
allow_any_instance_of(Lita::Handlers::Datadog).to \
|
32
|
+
receive(:graph_snapshot).with(any_args).and_return([500, nil])
|
33
|
+
send_command('graph metric:"omg.wtf.bbq{*}"')
|
34
|
+
expect(replies.last).to eq('Error requesting Datadog graph')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start { add_filter '/spec/' }
|
8
|
+
|
9
|
+
require 'lita-datadog'
|
10
|
+
require 'lita/rspec'
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-datadog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Sigler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dogapi
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.0.beta2
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0.beta2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: A Lita handler for interacting with Datadog
|
112
|
+
email:
|
113
|
+
- me@esigler.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rubocop.yml"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- lib/lita-datadog.rb
|
126
|
+
- lib/lita/handlers/datadog.rb
|
127
|
+
- lita-datadog.gemspec
|
128
|
+
- locales/en.yml
|
129
|
+
- spec/lita/handlers/datadog_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
homepage: http://github.com/esigler/lita-datadog
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata:
|
135
|
+
lita_plugin_type: handler
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.2.1
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Query metrics, events, and generate graphs from Datadog
|
156
|
+
test_files:
|
157
|
+
- spec/lita/handlers/datadog_spec.rb
|
158
|
+
- spec/spec_helper.rb
|