influxdb-plugin-fluent 1.4.0.pre.435 → 1.4.0.pre.485
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 +3 -0
- data/lib/fluent/plugin/out_influxdb2.rb +20 -8
- data/test/influxdb/plugin/output_test.rb +72 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddee4a28249f30200db356381844ee4b7493fceb5ea3516b1df7279de9554871
|
4
|
+
data.tar.gz: 5173f352ed233ab51e68ab3975389134ec2479359c15fcaca77e5b270dedeeeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf42a894b657cab073ba747eb3cfffed265751e23e7279b4c0694e27558f427f893e887b4dfa1f7aadcd91599519dccea577b772759d3802aaf4b4ed687f7b2e
|
7
|
+
data.tar.gz: 1bbbeef96cd3e8254dda96444e50d9be16596072d5f25a75daceda9abad28aad649a37b4004511000347b9e0968cc33b29ba2e6ea9f97e051083f98603e2bccd
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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.0.pre.
|
4
|
+
version: 1.4.0.pre.485
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|