fluent-plugin-influxdb-v2 1.9.0.pre.1169 → 1.9.0.pre.1341
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +10 -7
- data/.github/PULL_REQUEST_TEMPLATE +1 -1
- data/CHANGELOG.md +12 -0
- data/README.md +1 -0
- data/fluent-plugin-influxdb-v2.gemspec +1 -1
- data/lib/fluent/plugin/out_influxdb2.rb +46 -18
- data/test/.rubocop.yml +26 -0
- data/test/influxdb/plugin/output_test.rb +111 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e01f201d71085c9b0a82def242dd80df362cf783cc4bd22cdd280748bb2fea8f
|
4
|
+
data.tar.gz: fd52d6977a87054dd6805f3c0a8e825f11a0d680119445a48d38d436e32dbf11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ef6bb9981eaac83e2394892838edf29286672e98adf72a9183f2d088403cc24ee07c01a87726b3647a727ba5eb4e51f139b3814960c3541a9ab2535b0cf00dd
|
7
|
+
data.tar.gz: 52486af50894534c7d05f42c97c736a7d748e7103edc20505164a6ba6822fa13fb25de6e714df4d06f296c7e65b9b9f6c06f01b6cab1a1b58ea47a6cdbf9bd94
|
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 "
|
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: "
|
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: "
|
133
|
+
ruby-image: "cimg/ruby:2.5"
|
131
134
|
- tests-ruby:
|
132
135
|
name: ruby-2.4
|
133
|
-
ruby-image: "
|
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/
|
16
|
+
- [ ] Sign [CLA](https://www.influxdata.com/legal/cla/) (if not already signed)
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## 1.9.0 [unreleased]
|
2
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
|
+
1. [#31](https://github.com/influxdata/influxdb-plugin-fluent/pull/31): Add possibility to use LineProtocol from Fluetd's record.
|
6
|
+
|
7
|
+
### Dependencies
|
8
|
+
1. [#30](https://github.com/influxdata/influxdb-plugin-fluent/pull/30): Update dependencies:
|
9
|
+
- influxdb-client to 2.1.0
|
10
|
+
|
11
|
+
### CI
|
12
|
+
1. [#27](https://github.com/influxdata/influxdb-plugin-fluent/pull/27): Switch to next-gen CircleCI's convenience images
|
13
|
+
1. [#30](https://github.com/influxdata/influxdb-plugin-fluent/pull/30): Add Ruby 3.0 into CI
|
14
|
+
|
3
15
|
## 1.8.0 [2021-08-20]
|
4
16
|
|
5
17
|
### Features
|
data/README.md
CHANGED
@@ -45,6 +45,7 @@ Store Fluentd event to InfluxDB 2 database.
|
|
45
45
|
| field_cast_to_float | Turn on/off auto casting Integer value to Float. Helper to avoid mismatch error: 'series type mismatch: already Integer but got Float'. | bool | false |
|
46
46
|
| time_precision | The time precision of timestamp. You should specify either second (s), millisecond (ms), microsecond (us), or nanosecond (ns). | String | ns |
|
47
47
|
| time_key | A name of the record key that used as a 'timestamp' instead of event timestamp. If a record key doesn't exists or hasn't value then is used event timestamp. | String | nil |
|
48
|
+
| line_protocol_key | A name of the record key that contains [LineProtocol](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/). The value of this key is used for ingesting data into InfluxDB. If a record key doesn't exists or hasn't value then is used event timestamp. | String | nil |
|
48
49
|
|
49
50
|
##### Minimal configuration
|
50
51
|
|
@@ -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.
|
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'
|
@@ -73,6 +73,11 @@ class InfluxDBOutput < Fluent::Plugin::Output
|
|
73
73
|
desc 'A name of the record key that used as a \'timestamp\' instead of event timestamp.' \
|
74
74
|
'If a record key doesn\'t exists or hasn\'t value then is used event timestamp.'
|
75
75
|
|
76
|
+
config_param :line_protocol_key, :string, default: nil
|
77
|
+
desc 'A name of the record key that contains \'LineProtocol\'.' \
|
78
|
+
'The value of this key is used for ingesting data into InfluxDB.' \
|
79
|
+
'For more info see - https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/.'
|
80
|
+
|
76
81
|
config_section :buffer do
|
77
82
|
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
78
83
|
config_set_default :chunk_keys, ['tag']
|
@@ -121,28 +126,30 @@ class InfluxDBOutput < Fluent::Plugin::Output
|
|
121
126
|
tag = chunk.metadata.tag
|
122
127
|
bucket, measurement = expand_placeholders(chunk)
|
123
128
|
chunk.msgpack_each do |time, record|
|
124
|
-
if
|
125
|
-
|
129
|
+
if @line_protocol_key
|
130
|
+
points << record[@line_protocol_key] if record.include?(@line_protocol_key)
|
126
131
|
else
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
_parse_field(k, v, point)
|
132
|
+
time_formatted = _format_time(time)
|
133
|
+
point = InfluxDB2::Point
|
134
|
+
.new(name: measurement)
|
135
|
+
record.each_pair do |k, v|
|
136
|
+
if k.eql?(@time_key)
|
137
|
+
time_formatted = _format_time(v)
|
138
|
+
else
|
139
|
+
_parse_field(k, v, point)
|
140
|
+
end
|
141
|
+
point.add_tag('fluentd', tag) if @tag_fluentd
|
138
142
|
end
|
139
|
-
point.
|
143
|
+
point.time(time_formatted, @precision)
|
144
|
+
points << point
|
140
145
|
end
|
141
|
-
point.time(time_formatted, @precision)
|
142
|
-
points << point
|
143
146
|
end
|
144
|
-
|
145
|
-
|
147
|
+
if points.empty?
|
148
|
+
log.debug "Nothing to write for chunk: #{chunk.metadata}"
|
149
|
+
else
|
150
|
+
@write_api.write(data: points, bucket: bucket)
|
151
|
+
log.debug "Written points: #{points}"
|
152
|
+
end
|
146
153
|
end
|
147
154
|
|
148
155
|
private
|
@@ -157,6 +164,27 @@ class InfluxDBOutput < Fluent::Plugin::Output
|
|
157
164
|
[bucket, measurement]
|
158
165
|
end
|
159
166
|
|
167
|
+
def _format_time(time)
|
168
|
+
if time.is_a?(Integer)
|
169
|
+
time
|
170
|
+
elsif time.is_a?(Float)
|
171
|
+
time
|
172
|
+
elsif time.is_a?(Fluent::EventTime)
|
173
|
+
nano_seconds = time.sec * 1e9
|
174
|
+
nano_seconds += time.nsec
|
175
|
+
@precision_formatter.call(nano_seconds)
|
176
|
+
elsif time.is_a?(String)
|
177
|
+
begin
|
178
|
+
_format_time(Fluent::EventTime.parse(time))
|
179
|
+
rescue StandardError => e
|
180
|
+
log.debug "Cannot parse timestamp: #{time} due: #{e}"
|
181
|
+
time
|
182
|
+
end
|
183
|
+
else
|
184
|
+
time
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
160
188
|
def _parse_field(key, value, point)
|
161
189
|
if @tag_keys.include?(key)
|
162
190
|
point.add_tag(key, value)
|
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)
|
@@ -510,4 +586,39 @@ class InfluxDBOutputTest < Minitest::Test
|
|
510
586
|
assert_requested(:post, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
511
587
|
times: 1, body: 'placeholder_h2o_tag level=2i,location="europe" 1444897215000000000')
|
512
588
|
end
|
589
|
+
|
590
|
+
def test_line_protocol
|
591
|
+
stub_request(:any, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
592
|
+
.to_return(status: 204)
|
593
|
+
driver = create_driver(%(
|
594
|
+
@type influxdb2
|
595
|
+
token my-token
|
596
|
+
bucket my-bucket
|
597
|
+
org my-org
|
598
|
+
time_precision ns
|
599
|
+
line_protocol_key lp_key
|
600
|
+
))
|
601
|
+
driver.run(default_tag: 'h2o_tag') do
|
602
|
+
emit_documents(driver, 'location' => 'europe', 'level' => 2, 'lp_key' => 'mem,tag=1 field=10 102030')
|
603
|
+
end
|
604
|
+
assert_requested(:post, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
605
|
+
times: 1, body: 'mem,tag=1 field=10 102030')
|
606
|
+
end
|
607
|
+
|
608
|
+
def test_line_protocol_not_defined
|
609
|
+
stub_request(:any, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns')
|
610
|
+
.to_return(status: 204)
|
611
|
+
driver = create_driver(%(
|
612
|
+
@type influxdb2
|
613
|
+
token my-token
|
614
|
+
bucket my-bucket
|
615
|
+
org my-org
|
616
|
+
time_precision ns
|
617
|
+
line_protocol_key lp_key
|
618
|
+
))
|
619
|
+
driver.run(default_tag: 'h2o_tag') do
|
620
|
+
emit_documents(driver)
|
621
|
+
end
|
622
|
+
assert_requested(:post, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns', times: 0)
|
623
|
+
end
|
513
624
|
end
|
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.9.0.pre.
|
4
|
+
version: 1.9.0.pre.1341
|
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-
|
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.
|
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.
|
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
|
@@ -226,11 +227,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
227
|
- !ruby/object:Gem::Version
|
227
228
|
version: 1.3.1
|
228
229
|
requirements: []
|
229
|
-
rubygems_version: 3.
|
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
|