influxdb-plugin-fluent 1.3.0.pre.345 → 1.4.0.pre.497

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: 5d548430a940f69793c4cccf596c7f88ec6454c9440f556a62b0dec48b84e554
4
- data.tar.gz: 6d5cb461cd9ccad3fbb2b669076799e0448b97169a53ccee54a76c50aa68db42
3
+ metadata.gz: e02ded22bb53c91121089eb95d644da022510bdce638dc809bf4110f0191b10c
4
+ data.tar.gz: 406f55e543323cbc4a5f5ba7dc966846ed6309c006294625ab00d17d715202ae
5
5
  SHA512:
6
- metadata.gz: d2cfdc82df337c4f1027113e6d03a9fa976b28acaa687edd62558298b33df407b952df90002848214a4407821c9b7b8576234538d7415dadf3c1961571f569b8
7
- data.tar.gz: f9509309bc8c563b7b00ae3ed77ce78a47a17d30439989dced4da919398dc5cd9541a0e64467909de0d4d6e376ca57a866fb029f887e784ef7ffd997ea56db25
6
+ metadata.gz: 9549c858749f812597b747b286f0476c07dc69af46a26600f147cb637f32f9e91de4906c1f263d615dc142ccc3fc80e0ab820888e22792ee1765df3976bec079
7
+ data.tar.gz: 1792a00de281f6a6f4e65e9c7e48850405404e5b4c610632bf5f000e547b405c115c47c11a8cf0791e73646aba7ae34897c005fe7734654dc0ccf892edc92c28
@@ -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.3.0 [unreleased]
1
+ ## 1.4.0 [unreleased]
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]
10
+
11
+ ### Dependencies
12
+ 1. [#6](https://github.com/influxdata/influxdb-plugin-fluent/pull/6): Upgrade InfluxDB client to 1.4.0
2
13
 
3
14
  ## 1.2.0 [2020-03-13]
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.2.0
22
+ fluent-gem install influxdb-plugin-fluent -v 1.3.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.2.0'
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'
@@ -19,7 +19,7 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  require 'fluent/plugin/output'
22
- require 'influxdb2/client'
22
+ require 'influxdb-client'
23
23
 
24
24
  # A buffered output plugin for Fluentd and InfluxDB 2
25
25
  class InfluxDBOutput < Fluent::Plugin::Output
@@ -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.3.0'.freeze
24
+ VERSION = '1.4.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.3.0.pre.345
4
+ version: 1.4.0.pre.497
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-03-13 00:00:00.000000000 Z
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.2.0
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.2.0
40
+ version: 1.5.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement