fluent-plugin-dd 0.1.0 → 0.1.1
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 +8 -8
- data/README.md +1 -0
- data/fluent-plugin-dd.gemspec +1 -1
- data/lib/fluent/plugin/out_dd.rb +10 -16
- data/spec/out_dd_spec.rb +70 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Mzg2ZDBiZmE5YmNmOGQzNzcyYTAzMjUxMGU3YmZmMmVmMmM1Mzk2OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWVkNzllMDY0NmZhYTc2NjI1ZjU2MjE5MjZhMzQxODQ0NjlmYWQxMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDRkY2M3NTdiMWVhMmM0OGUyYjRhNGE3YjM2ZGIzZTFiNTUxZmIyNDlhOTM5
|
10
|
+
OWNjNDQ0M2I5ZjUzODE2MTE4YTkwMDNjNGQ1OTBkY2ExOTQ2MDExZDM3OTAw
|
11
|
+
ZWVkNTc5ODk2OWNkMmU2YzRjMWJjZjU4MDM0ZTU0ZDIyMmQyNGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGMzM2M4MmZmNjhjODI1ZmViNmI2YjJhMDJjZDgzYzIwMDhlNmJiMWVmMWQy
|
14
|
+
NTJhYTRhZGExYjU2NzhkYjhhZDljNWI2Y2E2MTc4OTFjOGM2YzNmMDY2NzBi
|
15
|
+
ZGVjYTQ2ZjQ5YzEyMGViOThhZTcyZDNlNjQwMTU4MGJkMGI1N2E=
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Output plugin for Datadog
|
|
23
23
|
|
24
24
|
```sh
|
25
25
|
echo '{"metric":"some.metric.name", "value":50.0}' | fluent-cat datadog.metric
|
26
|
+
echo '{"metric":"some.metric.name", "value":100.0, "tag":"any.tag", "host":"any.host", "type":"gauge"}' | fluent-cat datadog.metric
|
26
27
|
```
|
27
28
|
|
28
29
|
## Contributing
|
data/fluent-plugin-dd.gemspec
CHANGED
data/lib/fluent/plugin/out_dd.rb
CHANGED
@@ -1,16 +1,10 @@
|
|
1
1
|
class Fluent::DdOutput < Fluent::BufferedOutput
|
2
|
-
include Fluent::SetTimeKeyMixin
|
3
|
-
include Fluent::SetTagKeyMixin
|
4
|
-
|
5
2
|
Fluent::Plugin.register_output('dd', self)
|
6
3
|
|
7
4
|
unless method_defined?(:log)
|
8
5
|
define_method('log') { $log }
|
9
6
|
end
|
10
7
|
|
11
|
-
config_set_default :include_time_key, true
|
12
|
-
config_set_default :include_tag_key, true
|
13
|
-
|
14
8
|
config_param :dd_api_key, :string
|
15
9
|
config_param :host, :string, :default => nil
|
16
10
|
|
@@ -18,7 +12,6 @@ class Fluent::DdOutput < Fluent::BufferedOutput
|
|
18
12
|
super
|
19
13
|
require 'dogapi'
|
20
14
|
require 'socket'
|
21
|
-
require 'time'
|
22
15
|
end
|
23
16
|
|
24
17
|
def start
|
@@ -45,31 +38,32 @@ class Fluent::DdOutput < Fluent::BufferedOutput
|
|
45
38
|
end
|
46
39
|
|
47
40
|
def format(tag, time, record)
|
48
|
-
record.to_msgpack
|
41
|
+
[tag, time, record].to_msgpack
|
49
42
|
end
|
50
43
|
|
51
44
|
def write(chunk)
|
52
45
|
enum = chunk.to_enum(:msgpack_each)
|
53
46
|
|
54
|
-
enum.select {|record|
|
47
|
+
enum.select {|tag, time, record|
|
55
48
|
unless record['metric']
|
56
|
-
log.warn("`metric` key does not exist: #{record.inspect}")
|
49
|
+
log.warn("`metric` key does not exist: #{[tag, time, record].inspect}")
|
57
50
|
end
|
58
51
|
|
59
52
|
record['metric']
|
60
|
-
}.chunk {|record|
|
61
|
-
record
|
53
|
+
}.chunk {|tag, time, record|
|
54
|
+
tag = record['tag'] || tag
|
55
|
+
[tag] + record.values_at('metric', 'host', 'type')
|
62
56
|
}.each {|i, records|
|
63
|
-
|
57
|
+
tag, metric, host, type = i
|
64
58
|
|
65
|
-
points = records.map do |record|
|
66
|
-
time = Time.
|
59
|
+
points = records.map do |tag, time, record|
|
60
|
+
time = Time.at(time)
|
67
61
|
value = record['value']
|
68
62
|
[time, value]
|
69
63
|
end
|
70
64
|
|
71
65
|
options = {}
|
72
|
-
options['tags'] =
|
66
|
+
options['tags'] = tag.split(',').map {|i| i.strip } if tag
|
73
67
|
options['host'] = host if host
|
74
68
|
options['type'] = type if type
|
75
69
|
|
data/spec/out_dd_spec.rb
CHANGED
@@ -59,6 +59,74 @@ describe Fluent::DdOutput do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
it 'should be called emit_points for each tag (tag is included in the record)' do
|
63
|
+
run_driver do |d, dog|
|
64
|
+
dog.should_receive(:emit_points).with(
|
65
|
+
"some.metric.name",
|
66
|
+
[[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
|
67
|
+
[Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
|
68
|
+
{"tags"=>["test.11"]}
|
69
|
+
)
|
70
|
+
|
71
|
+
dog.should_receive(:emit_points).with(
|
72
|
+
"some.metric.name",
|
73
|
+
[[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
|
74
|
+
[Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
|
75
|
+
{"tags"=>["test.21"]}
|
76
|
+
)
|
77
|
+
|
78
|
+
dog.should_receive(:emit_points).with(
|
79
|
+
"some.metric.name",
|
80
|
+
[[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
|
81
|
+
[Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
|
82
|
+
{"tags"=>["test.31"]}
|
83
|
+
)
|
84
|
+
|
85
|
+
d.emit({"metric" => "some.metric.name", "value" => 50.0, "tag" => "test.11"}, time)
|
86
|
+
d.emit({"metric" => "some.metric.name", "value" => 100.0, "tag" => "test.11"}, time)
|
87
|
+
|
88
|
+
d.emit({"metric" => "some.metric.name", "value" => 150.0, "tag" => "test.21"}, time)
|
89
|
+
d.emit({"metric" => "some.metric.name", "value" => 200.0, "tag" => "test.21"}, time)
|
90
|
+
|
91
|
+
d.emit({"metric" => "some.metric.name", "value" => 250.0, "tag" => "test.31"}, time)
|
92
|
+
d.emit({"metric" => "some.metric.name", "value" => 300.0, "tag" => "test.31"}, time)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should be called emit_points with multiple tags' do
|
97
|
+
run_driver do |d, dog|
|
98
|
+
dog.should_receive(:emit_points).with(
|
99
|
+
"some.metric.name",
|
100
|
+
[[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
|
101
|
+
[Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
|
102
|
+
{"tags"=>["test.12","test.13"]}
|
103
|
+
)
|
104
|
+
|
105
|
+
dog.should_receive(:emit_points).with(
|
106
|
+
"some.metric.name",
|
107
|
+
[[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
|
108
|
+
[Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
|
109
|
+
{"tags"=>["test.22","test.23"]}
|
110
|
+
)
|
111
|
+
|
112
|
+
dog.should_receive(:emit_points).with(
|
113
|
+
"some.metric.name",
|
114
|
+
[[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
|
115
|
+
[Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
|
116
|
+
{"tags"=>["test.32","test.33"]}
|
117
|
+
)
|
118
|
+
|
119
|
+
d.emit({"metric" => "some.metric.name", "value" => 50.0, "tag" => "test.12,test.13"}, time)
|
120
|
+
d.emit({"metric" => "some.metric.name", "value" => 100.0, "tag" => "test.12,test.13"}, time)
|
121
|
+
|
122
|
+
d.emit({"metric" => "some.metric.name", "value" => 150.0, "tag" => "test.22,test.23"}, time)
|
123
|
+
d.emit({"metric" => "some.metric.name", "value" => 200.0, "tag" => "test.22,test.23"}, time)
|
124
|
+
|
125
|
+
d.emit({"metric" => "some.metric.name", "value" => 250.0, "tag" => "test.32,test.33"}, time)
|
126
|
+
d.emit({"metric" => "some.metric.name", "value" => 300.0, "tag" => "test.32,test.33"}, time)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
62
130
|
it 'should be called emit_points for each host' do
|
63
131
|
run_driver do |d, dog|
|
64
132
|
dog.should_receive(:emit_points).with(
|
@@ -125,9 +193,9 @@ describe Fluent::DdOutput do
|
|
125
193
|
|
126
194
|
log = d.instance.log
|
127
195
|
log.should_receive(:warn)
|
128
|
-
.with('`metric` key does not exist: {"no metric"=>"some.metric.name", "value"=>51.0
|
196
|
+
.with('`metric` key does not exist: ["test.default", 1391832855, {"no metric"=>"some.metric.name", "value"=>51.0}]')
|
129
197
|
log.should_receive(:warn)
|
130
|
-
.with('`metric` key does not exist: {"no metric"=>"some.metric.name", "value"=>101.0
|
198
|
+
.with('`metric` key does not exist: ["test.default", 1391832855, {"no metric"=>"some.metric.name", "value"=>101.0}]')
|
131
199
|
|
132
200
|
d.emit({"no metric" => "some.metric.name", "value" => 51.0}, time)
|
133
201
|
d.emit({"no metric" => "some.metric.name", "value" => 101.0}, time)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-dd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|