fluent-plugin-influxdb-v2 1.9.0.pre.1328 → 1.10.0.pre.1476
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 +11 -0
- data/CHANGELOG.md +7 -1
- data/README.md +2 -1
- data/fluent-plugin-influxdb-v2.gemspec +1 -2
- data/lib/fluent/plugin/out_influxdb2.rb +26 -13
- data/lib/fluent/plugin/version.rb +1 -1
- data/test/influxdb/plugin/output_test.rb +35 -0
- data/test/test_helper.rb +2 -2
- metadata +6 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b1bc092f8b1c99bc986bd6d9dba0787b093a5ad7782860175c59a208639689a
|
4
|
+
data.tar.gz: 63a5c33f4e08cfbc1b8447e8429e42aca1a937a1c68f4567785535286e01d76b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5095425d9046a28ef0f558845e61be89550d4fa43541c8d7a657c59382a578a2aabd5965398f446023e5da9cfed3d2bf02ad1e1e1c16a95ccde3b7bac47ac9be
|
7
|
+
data.tar.gz: e2f4fe376f2b0259c90c927b808cb107eb7ef109e33c6ef4420d09e8eb7447da3880d91911b145b3483afeaca1617c8c124abe385ae75c6ce168672a5566afac
|
data/.circleci/config.yml
CHANGED
@@ -59,6 +59,17 @@ commands:
|
|
59
59
|
command: |
|
60
60
|
export MINITEST_REPORTER=JUnitReporter
|
61
61
|
bundle exec rake test
|
62
|
+
- run:
|
63
|
+
name: Collecting coverage reports
|
64
|
+
command: |
|
65
|
+
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
66
|
+
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
|
67
|
+
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
|
68
|
+
curl -s https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
|
69
|
+
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
|
70
|
+
shasum -a 256 -c codecov.SHA256SUM
|
71
|
+
chmod +x ./codecov
|
72
|
+
./codecov
|
62
73
|
- save_cache:
|
63
74
|
name: Saving Gem Cache
|
64
75
|
key: *cache-key
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
|
-
## 1.
|
1
|
+
## 1.10.0 [unreleased]
|
2
|
+
|
3
|
+
### CI
|
4
|
+
1. [#32](https://github.com/influxdata/influxdb-plugin-fluent/pull/32): Use new Codecov uploader for reporting code coverage
|
5
|
+
|
6
|
+
## 1.9.0 [2021-11-26]
|
2
7
|
|
3
8
|
### Features
|
4
9
|
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`)
|
10
|
+
1. [#31](https://github.com/influxdata/influxdb-plugin-fluent/pull/31): Add possibility to use LineProtocol from Fluetd's record.
|
5
11
|
|
6
12
|
### Dependencies
|
7
13
|
1. [#30](https://github.com/influxdata/influxdb-plugin-fluent/pull/30): Update 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/fluent-plugin-influxdb-v2). You can install the gem as follows:
|
20
20
|
|
21
21
|
```
|
22
|
-
fluent-gem install fluent-plugin-influxdb-v2 -v 1.
|
22
|
+
fluent-gem install fluent-plugin-influxdb-v2 -v 1.9.0
|
23
23
|
```
|
24
24
|
|
25
25
|
## Plugins
|
@@ -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
|
|
@@ -50,12 +50,11 @@ Gem::Specification.new do |spec|
|
|
50
50
|
spec.add_runtime_dependency 'influxdb-client', '2.1.0'
|
51
51
|
|
52
52
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
53
|
-
spec.add_development_dependency 'codecov', '~> 0.1.16'
|
54
53
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
55
54
|
spec.add_development_dependency 'minitest-reporters', '~> 1.4'
|
56
55
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
57
56
|
spec.add_development_dependency 'rubocop', '~> 0.66.0'
|
58
|
-
spec.add_development_dependency 'simplecov', '~>
|
57
|
+
spec.add_development_dependency 'simplecov-cobertura', '~> 1.4.2'
|
59
58
|
spec.add_development_dependency 'test-unit', '~> 3.3'
|
60
59
|
spec.add_development_dependency 'webmock', '~> 3.7'
|
61
60
|
end
|
@@ -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,22 +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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
if @line_protocol_key
|
130
|
+
points << record[@line_protocol_key] if record.include?(@line_protocol_key)
|
131
|
+
else
|
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
|
132
142
|
end
|
133
|
-
point.
|
143
|
+
point.time(time_formatted, @precision)
|
144
|
+
points << point
|
134
145
|
end
|
135
|
-
point.time(time_formatted, @precision)
|
136
|
-
points << point
|
137
146
|
end
|
138
|
-
|
139
|
-
|
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
|
140
153
|
end
|
141
154
|
|
142
155
|
private
|
@@ -586,4 +586,39 @@ class InfluxDBOutputTest < Minitest::Test
|
|
586
586
|
assert_requested(:post, 'https://localhost:8086/api/v2/write?bucket=my-bucket&org=my-org&precision=ns',
|
587
587
|
times: 1, body: 'placeholder_h2o_tag level=2i,location="europe" 1444897215000000000')
|
588
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
|
589
624
|
end
|
data/test/test_helper.rb
CHANGED
@@ -22,8 +22,8 @@ require 'simplecov'
|
|
22
22
|
SimpleCov.start
|
23
23
|
|
24
24
|
if ENV['CI'] == 'true'
|
25
|
-
require '
|
26
|
-
SimpleCov.formatter = SimpleCov::Formatter::
|
25
|
+
require 'simplecov-cobertura'
|
26
|
+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
27
27
|
end
|
28
28
|
|
29
29
|
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
|
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.
|
4
|
+
version: 1.10.0.pre.1476
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Bednar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: codecov
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.16
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.16
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: minitest
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,19 +109,19 @@ dependencies:
|
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: 0.66.0
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: simplecov
|
112
|
+
name: simplecov-cobertura
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - "~>"
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
117
|
+
version: 1.4.2
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
124
|
+
version: 1.4.2
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: test-unit
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
213
|
- !ruby/object:Gem::Version
|
228
214
|
version: 1.3.1
|
229
215
|
requirements: []
|
230
|
-
rubygems_version: 3.2.
|
216
|
+
rubygems_version: 3.2.32
|
231
217
|
signing_key:
|
232
218
|
specification_version: 4
|
233
219
|
summary: InfluxDB 2 output plugin for Fluentd
|