influxdb-plugin-fluent 1.3.0.pre.424 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +9 -1
- data/README.md +1 -1
- data/influxdb-plugin-fluent.gemspec +1 -1
- data/lib/fluent/plugin/out_influxdb2.rb +20 -8
- data/lib/fluent/plugin/version.rb +1 -1
- data/test/influxdb/plugin/output_test.rb +72 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4118da7a41c53a86604f171d8c5fe9d1682db3b3b24aecd288caa5eefe7007e9
|
4
|
+
data.tar.gz: 1343c0918632109da65a59981af659578fbb4e77e8cd13aba4f9191d8ad0d8a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b52fdc2ae1c4189e318169fa10d318edd30962a87e119d3a1768b240d62292113c4f6aeb53a4cc7593751a1bb4a4d1fe75e61d717eced1e1c818daaed3788b46
|
7
|
+
data.tar.gz: 2ce20867e4d0c74d4e16b7fec4bce165a300343ba7093ca7d69f9adf558db46e0a63bfba3f2795d86bdeffce661dbeb835943b7d02a681f5c96c7e99535fcef1
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
## 1.
|
1
|
+
## 1.4.0 [2020-06-19]
|
2
|
+
|
3
|
+
### Features
|
4
|
+
1. [#8](https://github.com/influxdata/influxdb-plugin-fluent/pull/8): Added support for nested fields
|
5
|
+
|
6
|
+
### Dependencies
|
7
|
+
1. [#9](https://github.com/influxdata/influxdb-plugin-fluent/pull/9): Upgrade InfluxDB client to 1.5.0
|
8
|
+
|
9
|
+
## 1.3.0 [2020-05-15]
|
2
10
|
|
3
11
|
### Dependencies
|
4
12
|
1. [#6](https://github.com/influxdata/influxdb-plugin-fluent/pull/6): Upgrade InfluxDB client to 1.4.0
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ This repository contains the reference Fluentd plugin for the InfluxDB 2.0.
|
|
19
19
|
The plugin is bundled as a gem and is hosted on [Rubygems](https://rubygems.org/gems/influxdb-plugin-fluent). You can install the gem as follows:
|
20
20
|
|
21
21
|
```
|
22
|
-
fluent-gem install influxdb-plugin-fluent -v 1.
|
22
|
+
fluent-gem install influxdb-plugin-fluent -v 1.4.0
|
23
23
|
```
|
24
24
|
|
25
25
|
## Plugins
|
@@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
|
|
47
47
|
spec.required_ruby_version = '>= 2.2.0'
|
48
48
|
|
49
49
|
spec.add_runtime_dependency 'fluentd', '~> 1.8'
|
50
|
-
spec.add_runtime_dependency 'influxdb-client', '1.
|
50
|
+
spec.add_runtime_dependency 'influxdb-client', '1.5.0'
|
51
51
|
|
52
52
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
53
53
|
spec.add_development_dependency 'codecov', '~> 0.1.16'
|
@@ -128,14 +128,8 @@ class InfluxDBOutput < Fluent::Plugin::Output
|
|
128
128
|
record.each_pair do |k, v|
|
129
129
|
if k.eql?(@time_key)
|
130
130
|
time_formatted = v
|
131
|
-
|
132
|
-
|
133
|
-
elsif @field_keys.empty? || @field_keys.include?(k)
|
134
|
-
if @field_cast_to_float & v.is_a?(Integer)
|
135
|
-
point.add_field(k, Float(v))
|
136
|
-
else
|
137
|
-
point.add_field(k, v)
|
138
|
-
end
|
131
|
+
else
|
132
|
+
_parse_field(k, v, point)
|
139
133
|
end
|
140
134
|
point.add_tag('fluentd', tag) if @tag_fluentd
|
141
135
|
end
|
@@ -145,4 +139,22 @@ class InfluxDBOutput < Fluent::Plugin::Output
|
|
145
139
|
@write_api.write(data: points)
|
146
140
|
log.debug "Written points: #{points}"
|
147
141
|
end
|
142
|
+
|
143
|
+
private
|
144
|
+
|
145
|
+
def _parse_field(key, value, point)
|
146
|
+
if @tag_keys.include?(key)
|
147
|
+
point.add_tag(key, value)
|
148
|
+
elsif @field_keys.empty? || @field_keys.include?(key)
|
149
|
+
if @field_cast_to_float & value.is_a?(Integer)
|
150
|
+
point.add_field(key, Float(value))
|
151
|
+
elsif value.is_a?(Hash)
|
152
|
+
value.each_pair do |nested_k, nested_v|
|
153
|
+
_parse_field("#{key}.#{nested_k}", nested_v, point)
|
154
|
+
end
|
155
|
+
else
|
156
|
+
point.add_field(key, value)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
148
160
|
end
|
@@ -363,6 +363,78 @@ class InfluxDBOutputTest < Minitest::Test
|
|
363
363
|
times: 1, body: 'h2o_tag level=2.0,location="europe" 1444897215000000000')
|
364
364
|
end
|
365
365
|
|
366
|
+
def test_nested_field
|
367
|
+
stub_request(:any, 'https://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
368
|
+
.to_return(status: 204)
|
369
|
+
driver = create_driver(%(
|
370
|
+
@type influxdb2
|
371
|
+
token my-token
|
372
|
+
bucket my-bucket
|
373
|
+
org my-org
|
374
|
+
time_precision ns
|
375
|
+
))
|
376
|
+
driver.run(default_tag: 'h2o_tag') do
|
377
|
+
emit_documents(driver, 'location' => 'europe', 'level' => 2,
|
378
|
+
'nest' => { 'key' => 'nested value', 'deep' => { 'deep-key' => 'deep-value' }, 'a' => 25 })
|
379
|
+
end
|
380
|
+
body = 'h2o_tag level=2i,location="europe",nest.a=25i,nest.deep.deep-key="deep-value",nest.key="nested value" ' \
|
381
|
+
'1444897215000000000'
|
382
|
+
assert_requested(:post, 'https://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
383
|
+
times: 1, body: body)
|
384
|
+
end
|
385
|
+
|
386
|
+
def test_kubernetes_structure
|
387
|
+
record = {
|
388
|
+
'docker' => { 'container_id' => '7ee0723e90d13df5ade6f5d524f23474461fcfeb48a90630d8b02b13c741550b' },
|
389
|
+
'kubernetes' => { 'container_name' => 'fluentd',
|
390
|
+
'namespace_name' => 'default',
|
391
|
+
'pod_name' => 'fluentd-49xk2',
|
392
|
+
'container_image' => 'rawkode/fluentd:1',
|
393
|
+
'container_image_id' =>
|
394
|
+
'docker://sha256:90c288b8a09cc6ae98b04078afb10d9c380c0603a47745403461435073460f97',
|
395
|
+
'pod_id' => 'c15ab1cb-0773-4ad7-a58b-f791ab34c62f',
|
396
|
+
'host' => 'minikube',
|
397
|
+
'labels' => {
|
398
|
+
'controller-revision-hash' => '57748799f7',
|
399
|
+
'pod-template-generation' => 2,
|
400
|
+
'app_kubernetes_io/instance' => 'fluentd',
|
401
|
+
'app_kubernetes_io/name' => 'fluentd'
|
402
|
+
},
|
403
|
+
'master_url' => 'https://10.96.0.1:443/api',
|
404
|
+
'namespace_id' => '2b0bc75c-323a-4f04-9eec-02255a8d0044' },
|
405
|
+
'log' => '2020-06-17 13:19:42 +0000 [info]: #0 [filter_kube_metadata] stats - namespace_cache_size: 2, '\
|
406
|
+
'pod_cache_size: 6, pod_cache_watch_updates: 1, namespace_cache_api_updates: 6, '\
|
407
|
+
'pod_cache_api_updates: 6, id_cache_miss: 6\n',
|
408
|
+
'stream' => 'stdout'
|
409
|
+
}
|
410
|
+
|
411
|
+
stub_request(:any, 'https://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
412
|
+
.to_return(status: 204)
|
413
|
+
driver = create_driver(%(
|
414
|
+
@type influxdb2
|
415
|
+
token my-token
|
416
|
+
bucket my-bucket
|
417
|
+
org my-org
|
418
|
+
time_precision ns
|
419
|
+
))
|
420
|
+
driver.run(default_tag: 'h2o_tag') do
|
421
|
+
emit_documents(driver, record)
|
422
|
+
end
|
423
|
+
body = 'h2o_tag docker.container_id="7ee0723e90d13df5ade6f5d524f23474461fcfeb48a90630d8b02b13c741550b",'\
|
424
|
+
'kubernetes.container_image="rawkode/fluentd:1",'\
|
425
|
+
'kubernetes.container_image_id="docker://sha256:90c288b8a09cc6ae98b04078afb10d9c380c0603a47745403461435073460f97",'\
|
426
|
+
'kubernetes.container_name="fluentd",kubernetes.host="minikube",'\
|
427
|
+
'kubernetes.labels.app_kubernetes_io/instance="fluentd",kubernetes.labels.app_kubernetes_io/name="fluentd",'\
|
428
|
+
'kubernetes.labels.controller-revision-hash="57748799f7",kubernetes.labels.pod-template-generation=2i,'\
|
429
|
+
'kubernetes.master_url="https://10.96.0.1:443/api",kubernetes.namespace_id="2b0bc75c-323a-4f04-9eec-02255a8d0044",'\
|
430
|
+
'kubernetes.namespace_name="default",kubernetes.pod_id="c15ab1cb-0773-4ad7-a58b-f791ab34c62f",'\
|
431
|
+
'kubernetes.pod_name="fluentd-49xk2",log="2020-06-17 13:19:42 +0000 [info]: #0 [filter_kube_metadata] stats - '\
|
432
|
+
'namespace_cache_size: 2, pod_cache_size: 6, pod_cache_watch_updates: 1, namespace_cache_api_updates: 6, '\
|
433
|
+
'pod_cache_api_updates: 6, id_cache_miss: 6\\\n",stream="stdout" 1444897215000000000'
|
434
|
+
assert_requested(:post, 'https://localhost:9999/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
435
|
+
times: 1, body: body)
|
436
|
+
end
|
437
|
+
|
366
438
|
def emit_documents(driver, data = { 'location' => 'europe', 'level' => 2 })
|
367
439
|
time = event_time('2015-10-15 8:20:15 UTC')
|
368
440
|
driver.feed(time, data)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb-plugin-fluent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Bednar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.5.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.5.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,9 +219,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
219
|
version: 2.2.0
|
220
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
221
|
requirements:
|
222
|
-
- - "
|
222
|
+
- - ">="
|
223
223
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
224
|
+
version: '0'
|
225
225
|
requirements: []
|
226
226
|
rubygems_version: 3.0.3
|
227
227
|
signing_key:
|