fluent-plugin-influxdb-v2 1.8.0 → 1.9.0.pre.1328

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c3381ef9bbedb530e14741508b58177aea828d09fc9e57453b7d31a186684e7
4
- data.tar.gz: e1bfea98483940eaf1e105a01b6c5f17fe0ba2d3b0a723fe0034c6c09955c205
3
+ metadata.gz: a162e715eaf1dee93dc05d613df4da916d5f81ef6321eefbf6e723961113e520
4
+ data.tar.gz: b79ade354978657ab2c2ef3c91e45101ce382a8b62a6a53fb39c0614a158df4b
5
5
  SHA512:
6
- metadata.gz: 18b5ee73d321b8ed10c5cf523387484ee2008bb3388d3fe1f1e0109149651c1c5c2befa080093b7080f7cc8178d097fbc2158b2b6a31ea552f2c144df153494e
7
- data.tar.gz: ec9e958aadcbb9f2dab99c101c44dd8ec923b94b05b5efe68f38bb586f003e63b55b39c30411e61e70eda38b81855a716267f0bfa28cae3524b46f98ffcb99e3
6
+ metadata.gz: 4013c2885ae49e89fdaa5c0f70a75dc60773a8a28e4496a575c1b659e6248d81facd6e7b445902775a003468c9ff4f29847f7103c6d2fae4fd1e7d8335c53af6
7
+ data.tar.gz: b730665dd393f67da8eba3ad5553093593ddec5325c3e7316d4af14afe640e04045b1d6b34983879fbe4e72bed6ee2d7a74dc9ed1610cc52746740f412ded8e2
data/.circleci/config.yml CHANGED
@@ -41,9 +41,9 @@ commands:
41
41
  - restore_cache:
42
42
  name: Restoring Gem Cache
43
43
  keys:
44
- - &cache-key gem-cache-{{ checksum "fluent-plugin-influxdb-v2.gemspec" }}-<< parameters.ruby-image >>
45
- - gem-cache-{{ checksum "fluent-plugin-influxdb-v2.gemspec" }}
46
- - gem-cache-
44
+ - &cache-key gem-cache-v3-{{ checksum "fluent-plugin-influxdb-v2.gemspec" }}-<< parameters.ruby-image >>
45
+ - gem-cache-v3-{{ checksum "fluent-plugin-influxdb-v2.gemspec" }}
46
+ - gem-cache-v3-
47
47
  - run:
48
48
  name: Install dependencies
49
49
  command: |
@@ -75,7 +75,7 @@ jobs:
75
75
  parameters:
76
76
  ruby-image:
77
77
  type: string
78
- default: &default-ruby-image "circleci/ruby:2.6-stretch"
78
+ default: &default-ruby-image "cimg/ruby:2.6"
79
79
  influxdb-image:
80
80
  type: string
81
81
  default: &default-influxdb-image "influxdb:latest"
@@ -119,7 +119,10 @@ workflows:
119
119
  jobs:
120
120
  - tests-ruby:
121
121
  name: ruby-2.7
122
- ruby-image: "circleci/ruby:2.7-buster"
122
+ ruby-image: "cimg/ruby:2.7"
123
+ - tests-ruby:
124
+ name: ruby-3.0
125
+ ruby-image: "cimg/ruby:3.0"
123
126
  - tests-ruby:
124
127
  name: ruby-2.6
125
128
  - tests-ruby:
@@ -127,10 +130,10 @@ workflows:
127
130
  influxdb-image: "quay.io/influxdb/influxdb:nightly"
128
131
  - tests-ruby:
129
132
  name: ruby-2.5
130
- ruby-image: "circleci/ruby:2.5-stretch"
133
+ ruby-image: "cimg/ruby:2.5"
131
134
  - tests-ruby:
132
135
  name: ruby-2.4
133
- ruby-image: "circleci/ruby:2.4-stretch"
136
+ ruby-image: "cimg/ruby:2.4"
134
137
  - deploy-preview:
135
138
  requires:
136
139
  - ruby-2.7
@@ -13,4 +13,4 @@ _Briefly describe your proposed changes:_
13
13
  - [ ] A test has been added if appropriate
14
14
  - [ ] `rake test` completes successfully
15
15
  - [ ] Commit messages are in [semantic format](https://seesparkbox.com/foundry/semantic_commit_messages)
16
- - [ ] Sign [CLA](https://influxdata.com/community/cla/) (if not already signed)
16
+ - [ ] Sign [CLA](https://www.influxdata.com/legal/cla/) (if not already signed)
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 1.9.0 [unreleased]
2
+
3
+ ### Features
4
+ 1. [#30](https://github.com/influxdata/influxdb-plugin-fluent/pull/30): Field value for `time_key` can be formatted date (`2021-11-05 09:15:49.487727165 +0000`, `2021-11-05T10:04:43.617216Z`)
5
+
6
+ ### Dependencies
7
+ 1. [#30](https://github.com/influxdata/influxdb-plugin-fluent/pull/30): Update dependencies:
8
+ - influxdb-client to 2.1.0
9
+
10
+ ### CI
11
+ 1. [#27](https://github.com/influxdata/influxdb-plugin-fluent/pull/27): Switch to next-gen CircleCI's convenience images
12
+ 1. [#30](https://github.com/influxdata/influxdb-plugin-fluent/pull/30): Add Ruby 3.0 into CI
13
+
1
14
  ## 1.8.0 [2021-08-20]
2
15
 
3
16
  ### Features
@@ -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.12.0'
50
+ spec.add_runtime_dependency 'influxdb-client', '2.1.0'
51
51
 
52
52
  spec.add_development_dependency 'bundler', '~> 2.0'
53
53
  spec.add_development_dependency 'codecov', '~> 0.1.16'
@@ -121,18 +121,12 @@ class InfluxDBOutput < Fluent::Plugin::Output
121
121
  tag = chunk.metadata.tag
122
122
  bucket, measurement = expand_placeholders(chunk)
123
123
  chunk.msgpack_each do |time, record|
124
- if time.is_a?(Integer)
125
- time_formatted = time
126
- else
127
- nano_seconds = time.sec * 1e9
128
- nano_seconds += time.nsec
129
- time_formatted = @precision_formatter.call(nano_seconds)
130
- end
124
+ time_formatted = _format_time(time)
131
125
  point = InfluxDB2::Point
132
126
  .new(name: measurement)
133
127
  record.each_pair do |k, v|
134
128
  if k.eql?(@time_key)
135
- time_formatted = v
129
+ time_formatted = _format_time(v)
136
130
  else
137
131
  _parse_field(k, v, point)
138
132
  end
@@ -157,6 +151,27 @@ class InfluxDBOutput < Fluent::Plugin::Output
157
151
  [bucket, measurement]
158
152
  end
159
153
 
154
+ def _format_time(time)
155
+ if time.is_a?(Integer)
156
+ time
157
+ elsif time.is_a?(Float)
158
+ time
159
+ elsif time.is_a?(Fluent::EventTime)
160
+ nano_seconds = time.sec * 1e9
161
+ nano_seconds += time.nsec
162
+ @precision_formatter.call(nano_seconds)
163
+ elsif time.is_a?(String)
164
+ begin
165
+ _format_time(Fluent::EventTime.parse(time))
166
+ rescue StandardError => e
167
+ log.debug "Cannot parse timestamp: #{time} due: #{e}"
168
+ time
169
+ end
170
+ else
171
+ time
172
+ end
173
+ end
174
+
160
175
  def _parse_field(key, value, point)
161
176
  if @tag_keys.include?(key)
162
177
  point.add_tag(key, value)
@@ -21,7 +21,7 @@
21
21
  module InfluxDB2
22
22
  module Plugin
23
23
  module Fluent
24
- VERSION = '1.8.0'.freeze
24
+ VERSION = '1.9.0'.freeze
25
25
  end
26
26
  end
27
27
  end
data/test/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ #
2
+ # The MIT License
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+
23
+ inherit_from: ../.rubocop.yml
24
+ Metrics/ClassLength:
25
+ Enabled: false
26
+
@@ -381,6 +381,82 @@ class InfluxDBOutputTest < Minitest::Test
381
381
  times: 1, body: 'h2o_tag,version=v.10 level=2i,location="europe" 1544897215000000000')
382
382
  end
383
383
 
384
+ def test_time_float
385
+ stub_request(:any, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
386
+ .to_return(status: 204)
387
+ driver = create_driver(%(
388
+ @type influxdb2
389
+ token my-token
390
+ bucket my-bucket
391
+ org my-org
392
+ tag_keys ["version"]
393
+ time_key time
394
+ ))
395
+ driver.run(default_tag: 'h2o_tag') do
396
+ emit_documents(driver, 'location' => 'europe', 'level' => 2, 'version' => 'v.10',
397
+ 'time' => 1_544_897_215_000_000_000.123)
398
+ end
399
+ assert_requested(:post, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
400
+ times: 1, body: 'h2o_tag,version=v.10 level=2i,location="europe" 1544897215000000000')
401
+ end
402
+
403
+ def test_time_key_rfc_3339_format
404
+ stub_request(:any, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
405
+ .to_return(status: 204)
406
+ driver = create_driver(%(
407
+ @type influxdb2
408
+ token my-token
409
+ bucket my-bucket
410
+ org my-org
411
+ tag_keys ["version"]
412
+ time_key time
413
+ ))
414
+ driver.run(default_tag: 'h2o_tag') do
415
+ emit_documents(driver, 'location' => 'europe', 'level' => 2, 'version' => 'v.10',
416
+ 'time' => '2021-11-05T10:04:43.617216Z')
417
+ end
418
+ assert_requested(:post, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
419
+ times: 1, body: 'h2o_tag,version=v.10 level=2i,location="europe" 1636106683617216000')
420
+ end
421
+
422
+ def test_time_key_log_format
423
+ stub_request(:any, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
424
+ .to_return(status: 204)
425
+ driver = create_driver(%(
426
+ @type influxdb2
427
+ token my-token
428
+ bucket my-bucket
429
+ org my-org
430
+ tag_keys ["version"]
431
+ time_key time
432
+ ))
433
+ driver.run(default_tag: 'h2o_tag') do
434
+ emit_documents(driver, 'location' => 'europe', 'level' => 2, 'version' => 'v.10',
435
+ 'time' => '2021-11-05 09:15:49.487727165 +0000')
436
+ end
437
+ assert_requested(:post, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
438
+ times: 1, body: 'h2o_tag,version=v.10 level=2i,location="europe" 1636103749487727104')
439
+ end
440
+
441
+ def test_time_key_not_parseable
442
+ stub_request(:any, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
443
+ .to_return(status: 204)
444
+ driver = create_driver(%(
445
+ @type influxdb2
446
+ token my-token
447
+ bucket my-bucket
448
+ org my-org
449
+ tag_keys ["version"]
450
+ time_key time
451
+ ))
452
+ driver.run(default_tag: 'h2o_tag') do
453
+ emit_documents(driver, 'location' => 'europe', 'level' => 2, 'version' => 'v.10',
454
+ 'time' => '1544897215000000000')
455
+ end
456
+ assert_requested(:post, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
457
+ times: 1, body: 'h2o_tag,version=v.10 level=2i,location="europe" 1544897215000000000')
458
+ end
459
+
384
460
  def test_field_cast_to_float
385
461
  stub_request(:any, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
386
462
  .to_return(status: 204)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-influxdb-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0.pre.1328
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Bednar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-20 00:00:00.000000000 Z
11
+ date: 2021-11-11 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.12.0
33
+ version: 2.1.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.12.0
40
+ version: 2.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -201,6 +201,7 @@ files:
201
201
  - lib/fluent/plugin/fluent.rb
202
202
  - lib/fluent/plugin/out_influxdb2.rb
203
203
  - lib/fluent/plugin/version.rb
204
+ - test/.rubocop.yml
204
205
  - test/influxdb/plugin/output_test.rb
205
206
  - test/influxdb/plugin/version_test.rb
206
207
  - test/test_helper.rb
@@ -222,15 +223,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
223
  version: 2.2.0
223
224
  required_rubygems_version: !ruby/object:Gem::Requirement
224
225
  requirements:
225
- - - ">="
226
+ - - ">"
226
227
  - !ruby/object:Gem::Version
227
- version: '0'
228
+ version: 1.3.1
228
229
  requirements: []
229
- rubygems_version: 3.0.3.1
230
+ rubygems_version: 3.2.22
230
231
  signing_key:
231
232
  specification_version: 4
232
233
  summary: InfluxDB 2 output plugin for Fluentd
233
234
  test_files:
235
+ - test/.rubocop.yml
234
236
  - test/influxdb/plugin/output_test.rb
235
237
  - test/influxdb/plugin/version_test.rb
236
238
  - test/test_helper.rb