influxdb-plugin-fluent 1.4.0.pre.435 → 1.5.0.pre.563

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de4b8e2ac011c9d9c3780c899325c2cf50d94c9ccc63d5c53b8be11e684bae26
4
- data.tar.gz: 6387b6209adb43985bbf5e6f152a1c2b4a2c3cfe0713c46fbf8d17ee6e5a1873
3
+ metadata.gz: 973f288a15c06fa35e0b29ed53f2f706223e51f0557b92e7e7f3436e2a93991e
4
+ data.tar.gz: 8506d54df262e5362098cdf985a1fc90dd2ed6ecf4ee96fef993b3e8484d7335
5
5
  SHA512:
6
- metadata.gz: 58bd834b73a02c53bec906d7d30a3fa575dfa7982060b70195c3b313cf145535cb76983ba2a691e7820817ed45525cacab408d689f6549eba8fb8c9007a9d2f5
7
- data.tar.gz: 20c1408758e91560c844f4695924b136fa7067b7ba294861dcd102368e3e8a4d0da5e2ebfccd9ec570fccca6a7272a6c1eacd8251fb6e113ded8e93b14261e49
6
+ metadata.gz: 78fcd35fb3980f3a14e4d6d36e2e080b64dc9b6ad0562b913030a81f3818bde03105665663ef3120f7caaec3ae4e0edd04254515be600ba326a09120453898d4
7
+ data.tar.gz: 25061fb356a9ffa69a640a627bf80e7bc4b203556caf8c12f2971840e4f12d4ea805cb7d60d1b9cfa6ecd97e57c8d118723d17fad422a15595b36b423591db8e
@@ -23,9 +23,9 @@
23
23
  Metrics/LineLength:
24
24
  Max: 120
25
25
  Metrics/MethodLength:
26
- Max: 40
26
+ Max: 50
27
27
  Metrics/ClassLength:
28
- Max: 350
28
+ Max: 500
29
29
  Metrics/AbcSize:
30
30
  Max: 40
31
31
  Metrics/BlockLength:
@@ -1,4 +1,15 @@
1
- ## 1.4.0 [unreleased]
1
+ ## 1.5.0 [unreleased]
2
+
3
+ ### Dependencies
4
+ 1. [#11](https://github.com/influxdata/influxdb-plugin-fluent/pull/11): Upgrade InfluxDB client to 1.6.0
5
+
6
+ ## 1.4.0 [2020-06-19]
7
+
8
+ ### Features
9
+ 1. [#8](https://github.com/influxdata/influxdb-plugin-fluent/pull/8): Added support for nested fields
10
+
11
+ ### Dependencies
12
+ 1. [#9](https://github.com/influxdata/influxdb-plugin-fluent/pull/9): Upgrade InfluxDB client to 1.5.0
2
13
 
3
14
  ## 1.3.0 [2020-05-15]
4
15
 
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.3.0
22
+ fluent-gem install influxdb-plugin-fluent -v 1.4.0
23
23
  ```
24
24
 
25
25
  ## Plugins
@@ -33,7 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.email = ['jakub.bednar@gmail.com']
34
34
 
35
35
  spec.summary = 'InfluxDB 2 output plugin for Fluentd'
36
- spec.description = 'A buffered output plugin for Fluentd and InfluxDB 2'
36
+ spec.description = 'The gem is renamed to fluent-plugin-influxdb-v2. '\
37
+ 'A buffered output plugin for Fluentd and InfluxDB 2'
37
38
  spec.homepage = 'https://github.com/influxdata/influxdb-plugin-fluent'
38
39
  spec.license = 'MIT'
39
40
 
@@ -47,7 +48,7 @@ Gem::Specification.new do |spec|
47
48
  spec.required_ruby_version = '>= 2.2.0'
48
49
 
49
50
  spec.add_runtime_dependency 'fluentd', '~> 1.8'
50
- spec.add_runtime_dependency 'influxdb-client', '1.4.0'
51
+ spec.add_runtime_dependency 'influxdb-client', '1.6.0'
51
52
 
52
53
  spec.add_development_dependency 'bundler', '~> 2.0'
53
54
  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
- elsif @tag_keys.include?(k)
132
- point.add_tag(k, v)
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
@@ -21,7 +21,7 @@
21
21
  module InfluxDB2
22
22
  module Plugin
23
23
  module Fluent
24
- VERSION = '1.4.0'.freeze
24
+ VERSION = '1.5.0'.freeze
25
25
  end
26
26
  end
27
27
  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.435
4
+ version: 1.5.0.pre.563
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-05-15 00:00:00.000000000 Z
11
+ date: 2020-07-17 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.4.0
33
+ version: 1.6.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.4.0
40
+ version: 1.6.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +164,8 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '3.7'
167
- description: A buffered output plugin for Fluentd and InfluxDB 2
167
+ description: The gem is renamed to fluent-plugin-influxdb-v2. A buffered output plugin
168
+ for Fluentd and InfluxDB 2
168
169
  email:
169
170
  - jakub.bednar@gmail.com
170
171
  executables: []