fluent-plugin-influxdb 0.2.6 → 0.2.7
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/History.md +5 -0
- data/README.md +5 -1
- data/fluent-plugin-influxdb.gemspec +1 -1
- data/lib/fluent/plugin/out_influxdb.rb +27 -2
- data/test/plugin/test_out_influxdb.rb +228 -58
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19ed5ac1760f771e950cd309fd82c7762b7ce0ba
|
4
|
+
data.tar.gz: c0ef1cc12321bd4270b46ad6f077302ae587a82f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5294012a219916c4cf1bf943c3980cedb6cd03f8c22553e5b4a8ac226cc7aa1866d6877b4332192e8c7899b74caf0282ebba9ac4029d16cf53fc1816ba4934da
|
7
|
+
data.tar.gz: 28663a91913a16451713e89b2278eb35b948c386a7154ab8b0c8535d079fab7ade8781e69caac7f5030a6e2c59fdf6e1a5c87236d83267b437f076a5da766301
|
data/History.md
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,10 @@ Just like other regular output plugins, Use type `influxdb` in your fluentd conf
|
|
43
43
|
|
44
44
|
`sequence_tag`: The name of the tag whose value is incremented for the consecutive simultaneous events and reset to zero for a new event with the different timestamp
|
45
45
|
|
46
|
+
`default_retention_policy`: The retention policy applied by default. influxdb >= 0.2.3 is required to use this functionality.
|
47
|
+
|
48
|
+
`retention_policy_key`: The name of the key in the record whose value specifies the retention policy. The default retention policy will be applied if no such key exists. influxdb >= 0.2.3 is required to use this functionality.
|
49
|
+
|
46
50
|
### Fluentd Tag and InfluxDB Series
|
47
51
|
|
48
52
|
influxdb plugin uses Fluentd event tag for InfluxDB series.
|
@@ -52,7 +56,7 @@ So if you have events with `app.event`, influxdb plugin inserts events into `app
|
|
52
56
|
|
53
57
|
```
|
54
58
|
<match mylog.*>
|
55
|
-
type influxdb
|
59
|
+
@type influxdb
|
56
60
|
host localhost
|
57
61
|
port 8086
|
58
62
|
dbname test
|
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-influxdb"
|
6
|
-
s.version = '0.2.
|
6
|
+
s.version = '0.2.7'
|
7
7
|
s.authors = ["Masahiro Nakagawa", "FangLi"]
|
8
8
|
s.email = ["repeatedly@gmail.com", "surivlee@gmail.com"]
|
9
9
|
s.description = %q{InfluxDB output plugin for Fluentd}
|
@@ -41,6 +41,10 @@ DESC
|
|
41
41
|
The name of the tag whose value is incremented for the consecutive simultaneous
|
42
42
|
events and reset to zero for a new event with the different timestamp.
|
43
43
|
DESC
|
44
|
+
config_param :retention_policy_key, :string, :default => nil,
|
45
|
+
:desc => "The key of the key in the record that stores the retention policy name"
|
46
|
+
config_param :default_retention_policy, :string, :default => nil,
|
47
|
+
:desc => "The name of the default retention policy"
|
44
48
|
|
45
49
|
|
46
50
|
def initialize
|
@@ -131,9 +135,30 @@ DESC
|
|
131
135
|
:values => values,
|
132
136
|
:tags => tags,
|
133
137
|
}
|
134
|
-
|
138
|
+
retention_policy = @default_retention_policy
|
139
|
+
unless @retention_policy_key.nil?
|
140
|
+
retention_policy = record.delete(@retention_policy_key) || @default_retention_policy
|
141
|
+
unless points.nil?
|
142
|
+
if retention_policy != @default_retention_policy
|
143
|
+
# flush the retention policy first
|
144
|
+
@influxdb.write_points(points, nil, @default_retention_policy)
|
145
|
+
points = nil
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
if points.nil?
|
150
|
+
@influxdb.write_points([point], nil, retention_policy)
|
151
|
+
else
|
152
|
+
points << point
|
153
|
+
end
|
135
154
|
end
|
136
155
|
|
137
|
-
|
156
|
+
unless points.nil?
|
157
|
+
if @default_retention_policy.nil?
|
158
|
+
@influxdb.write_points(points)
|
159
|
+
else
|
160
|
+
@influxdb.write_points(points, nil, @default_retention_policy)
|
161
|
+
end
|
162
|
+
end
|
138
163
|
end
|
139
164
|
end
|
@@ -12,11 +12,11 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
12
12
|
[{'name' => 'test'}]
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
@points += points
|
15
|
+
def stop!
|
17
16
|
end
|
18
17
|
|
19
|
-
def
|
18
|
+
def write_points(points, precision=nil, retention_policy=nil)
|
19
|
+
@points << [points, precision, retention_policy]
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -42,7 +42,7 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
42
42
|
def create_driver(conf=CONFIG, tag='test')
|
43
43
|
Fluent::Test::BufferedOutputTestDriver.new(Fluent::InfluxdbOutput, tag) do
|
44
44
|
attr_reader :influxdb
|
45
|
-
def
|
45
|
+
def configure(conf)
|
46
46
|
@influxdb = DummyInfluxDBClient.new()
|
47
47
|
super
|
48
48
|
end
|
@@ -83,18 +83,24 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
83
83
|
data = driver.run
|
84
84
|
|
85
85
|
assert_equal([
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
},
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
}
|
86
|
+
[
|
87
|
+
[
|
88
|
+
{
|
89
|
+
:timestamp => time,
|
90
|
+
:series => 'input.influxdb',
|
91
|
+
:tags => {},
|
92
|
+
:values => {'a' => 1}
|
93
|
+
},
|
94
|
+
{
|
95
|
+
:timestamp => time,
|
96
|
+
:series => 'input.influxdb',
|
97
|
+
:tags => {},
|
98
|
+
:values => {'a' => 2}
|
99
|
+
},
|
100
|
+
],
|
101
|
+
nil,
|
102
|
+
nil
|
103
|
+
]
|
98
104
|
], driver.instance.influxdb.points)
|
99
105
|
|
100
106
|
end
|
@@ -116,24 +122,30 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
116
122
|
data = driver.run
|
117
123
|
|
118
124
|
assert_equal([
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
{
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
{
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
125
|
+
[
|
126
|
+
[
|
127
|
+
{
|
128
|
+
:timestamp => time,
|
129
|
+
:series => 'input.influxdb',
|
130
|
+
:values => {'a' => 1},
|
131
|
+
:tags => {},
|
132
|
+
},
|
133
|
+
{
|
134
|
+
:timestamp => time,
|
135
|
+
:series => 'input.influxdb',
|
136
|
+
:values => {'a' => 2},
|
137
|
+
:tags => {'b' => 1},
|
138
|
+
},
|
139
|
+
{
|
140
|
+
:timestamp => time,
|
141
|
+
:series => 'input.influxdb',
|
142
|
+
:values => {'a' => 3},
|
143
|
+
:tags => {},
|
144
|
+
},
|
145
|
+
],
|
146
|
+
nil,
|
147
|
+
nil
|
148
|
+
]
|
137
149
|
], driver.instance.influxdb.points)
|
138
150
|
end
|
139
151
|
|
@@ -161,30 +173,188 @@ class InfluxdbOutputTest < Test::Unit::TestCase
|
|
161
173
|
data = driver.run
|
162
174
|
|
163
175
|
assert_equal([
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
{
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
{
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
{
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
176
|
+
[
|
177
|
+
[
|
178
|
+
{
|
179
|
+
:timestamp => time,
|
180
|
+
:series => 'input.influxdb',
|
181
|
+
:values => {'a' => 1},
|
182
|
+
:tags => {'_seq' => 0},
|
183
|
+
},
|
184
|
+
{
|
185
|
+
:timestamp => time,
|
186
|
+
:series => 'input.influxdb',
|
187
|
+
:values => {'a' => 2},
|
188
|
+
:tags => {'_seq' => 1},
|
189
|
+
},
|
190
|
+
{
|
191
|
+
:timestamp => time + 1,
|
192
|
+
:series => 'input.influxdb',
|
193
|
+
:values => {'a' => 1},
|
194
|
+
:tags => {'_seq' => 0},
|
195
|
+
},
|
196
|
+
{
|
197
|
+
:timestamp => time + 1,
|
198
|
+
:series => 'input.influxdb',
|
199
|
+
:values => {'a' => 2},
|
200
|
+
:tags => {'_seq' => 1},
|
201
|
+
}
|
202
|
+
],
|
203
|
+
nil,
|
204
|
+
nil
|
205
|
+
]
|
206
|
+
], driver.instance.influxdb.points)
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_write_default_retention_policy_only
|
211
|
+
config = CONFIG + "\n" + %[
|
212
|
+
default_retention_policy ephemeral_1d
|
213
|
+
]
|
214
|
+
driver = create_driver(config, 'input.influxdb')
|
215
|
+
|
216
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
217
|
+
driver.emit({'a' => 1}, time)
|
218
|
+
driver.emit({'a' => 2}, time)
|
219
|
+
|
220
|
+
data = driver.run
|
221
|
+
|
222
|
+
assert_equal([
|
223
|
+
[
|
224
|
+
[
|
225
|
+
{
|
226
|
+
:timestamp => time,
|
227
|
+
:series => 'input.influxdb',
|
228
|
+
:tags => {},
|
229
|
+
:values => {'a' => 1}
|
230
|
+
},
|
231
|
+
{
|
232
|
+
:timestamp => time,
|
233
|
+
:series => 'input.influxdb',
|
234
|
+
:tags => {},
|
235
|
+
:values => {'a' => 2}
|
236
|
+
},
|
237
|
+
],
|
238
|
+
nil,
|
239
|
+
'ephemeral_1d'
|
240
|
+
]
|
188
241
|
], driver.instance.influxdb.points)
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_write_respective_retention_policy
|
246
|
+
config = CONFIG + "\n" + %[
|
247
|
+
retention_policy_key rp
|
248
|
+
]
|
249
|
+
driver = create_driver(config, 'input.influxdb')
|
250
|
+
|
251
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
252
|
+
driver.emit({'a' => 1}, time)
|
253
|
+
driver.emit({'a' => 2, 'rp' => 'ephemeral_1d'}, time)
|
254
|
+
driver.emit({'a' => 3, 'rp' => 'ephemeral_1m'}, time)
|
255
|
+
|
256
|
+
data = driver.run
|
257
|
+
|
258
|
+
assert_equal([
|
259
|
+
[
|
260
|
+
[
|
261
|
+
{
|
262
|
+
:timestamp => time,
|
263
|
+
:series => 'input.influxdb',
|
264
|
+
:tags => {},
|
265
|
+
:values => {'a' => 1},
|
266
|
+
}
|
267
|
+
],
|
268
|
+
nil,
|
269
|
+
nil
|
270
|
+
],
|
271
|
+
[
|
272
|
+
[
|
273
|
+
{
|
274
|
+
:timestamp => time,
|
275
|
+
:series => 'input.influxdb',
|
276
|
+
:tags => {},
|
277
|
+
:values => {'a' => 2},
|
278
|
+
}
|
279
|
+
],
|
280
|
+
nil,
|
281
|
+
'ephemeral_1d'
|
282
|
+
],
|
283
|
+
[
|
284
|
+
[
|
285
|
+
{
|
286
|
+
:timestamp => time,
|
287
|
+
:series => 'input.influxdb',
|
288
|
+
:tags => {},
|
289
|
+
:values => {'a' => 3},
|
290
|
+
}
|
291
|
+
],
|
292
|
+
nil,
|
293
|
+
'ephemeral_1m'
|
294
|
+
]
|
295
|
+
], driver.instance.influxdb.points)
|
296
|
+
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_write_combined_retention_policy
|
300
|
+
config = CONFIG + "\n" + %[
|
301
|
+
default_retention_policy ephemeral_1d
|
302
|
+
retention_policy_key rp
|
303
|
+
]
|
304
|
+
driver = create_driver(config, 'input.influxdb')
|
305
|
+
|
306
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
307
|
+
driver.emit({'a' => 1}, time)
|
308
|
+
driver.emit({'a' => 2, 'rp' => 'ephemeral_1d'}, time)
|
309
|
+
driver.emit({'a' => 3, 'rp' => 'ephemeral_1m'}, time)
|
310
|
+
driver.emit({'a' => 4}, time)
|
311
|
+
|
312
|
+
data = driver.run
|
313
|
+
|
314
|
+
assert_equal([
|
315
|
+
[
|
316
|
+
[
|
317
|
+
{
|
318
|
+
:timestamp => time,
|
319
|
+
:series => 'input.influxdb',
|
320
|
+
:tags => {},
|
321
|
+
:values => {'a' => 1},
|
322
|
+
},
|
323
|
+
{
|
324
|
+
:timestamp => time,
|
325
|
+
:series => 'input.influxdb',
|
326
|
+
:tags => {},
|
327
|
+
:values => {'a' => 2},
|
328
|
+
}
|
329
|
+
],
|
330
|
+
nil,
|
331
|
+
'ephemeral_1d'
|
332
|
+
],
|
333
|
+
[
|
334
|
+
[
|
335
|
+
{
|
336
|
+
:timestamp => time,
|
337
|
+
:series => 'input.influxdb',
|
338
|
+
:tags => {},
|
339
|
+
:values => {'a' => 3},
|
340
|
+
}
|
341
|
+
],
|
342
|
+
nil,
|
343
|
+
'ephemeral_1m'
|
344
|
+
],
|
345
|
+
[
|
346
|
+
[
|
347
|
+
{
|
348
|
+
:timestamp => time,
|
349
|
+
:series => 'input.influxdb',
|
350
|
+
:tags => {},
|
351
|
+
:values => {'a' => 4},
|
352
|
+
}
|
353
|
+
],
|
354
|
+
nil,
|
355
|
+
'ephemeral_1d'
|
356
|
+
]
|
357
|
+
], driver.instance.influxdb.points)
|
358
|
+
|
189
359
|
end
|
190
360
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-influxdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Nakagawa
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.5.1
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: A buffered output plugin for fluentd and influxDB
|