influxdb-plugin-fluent 1.3.0 → 1.5.0.pre.508

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: 46ea5f5ff15b625da7d272931c2026d445cc471b8272556dce05d1bd771fe330
4
- data.tar.gz: 0afa38309b6b215e6d82a72c870c3c1c8c5e22adc550875e2a6d5a28f758d0ec
3
+ metadata.gz: 2046691f014b363e35347acd877dd0fe17369bd7fea63f583486bcfadb383eec
4
+ data.tar.gz: 1527a4f490b217aec92bb7e1aa2fee6be009ea246d7cb5b69f3abd8852efa3d7
5
5
  SHA512:
6
- metadata.gz: 8aff8eed0a8f68d93eec3d5720ff244f90b5b07716215c37d825a730e11aab8565aae91d7f1bb12ba4f437b19d8c68933f7ff2a57ba80251dea1c51de6290e6c
7
- data.tar.gz: 12ae04090f6b8406f09050cb12b6b82e017715bc1450bd70ad7d68276483433214a9ab33b13ad2e4814c3da2bc26c0838566a5b06f0600d5d0f36f5a64ae27e0
6
+ metadata.gz: b799561e331c147cf37a88adf5fc5fa791296ef11af5333fcd884ab50e9b7340d0d3bcd0d2c7ba3f2ff586402ae0e859c859d90ca780337a5e07a51fe5736b0d
7
+ data.tar.gz: dcb0a36d6c4dfc9fa978bb0816f9f344bdcf580fddfc5cf54d62374fb74eb065911341e09720068208b80860248ba2b42569bef5fd999050f66d3b836d38cfe2
@@ -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,3 +1,13 @@
1
+ ## 1.5.0 [unreleased]
2
+
3
+ ## 1.4.0 [2020-06-19]
4
+
5
+ ### Features
6
+ 1. [#8](https://github.com/influxdata/influxdb-plugin-fluent/pull/8): Added support for nested fields
7
+
8
+ ### Dependencies
9
+ 1. [#9](https://github.com/influxdata/influxdb-plugin-fluent/pull/9): Upgrade InfluxDB client to 1.5.0
10
+
1
11
  ## 1.3.0 [2020-05-15]
2
12
 
3
13
  ### Dependencies
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
@@ -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.4.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'
@@ -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.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.3.0
4
+ version: 1.5.0.pre.508
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-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.4.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.4.0
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: '0'
224
+ version: 1.3.1
225
225
  requirements: []
226
226
  rubygems_version: 3.0.3
227
227
  signing_key: