fluent-plugin-concat 2.3.0 → 2.4.0
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 +4 -4
- data/.rubocop.yml +11 -8
- data/.travis.yml +8 -10
- data/Appraisals +0 -3
- data/README.md +35 -12
- data/fluent-plugin-concat.gemspec +2 -2
- data/lib/fluent/plugin/filter_concat.rb +73 -8
- metadata +7 -9
- data/gemfiles/fluentd_v0.14.gemfile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d906b3c9372b21adec5b1515e4820b037d90a0fa83a32f01dad1a8d6e5e0f79c
|
4
|
+
data.tar.gz: 9685f06e791e53ae0fcb3bb3e71991f812405298084c31cb4cc61a4181e17d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1683fcfe93f86fedbc89334dde6565b48fad41800631a5624ebfd26f89f8c725c0cff1aed9ef3733d863bf1ec3fb2e0e62676ce78a68dc40d332b08f80209748
|
7
|
+
data.tar.gz: 6bec85d758dfce0dbced83a03413d2e1c2cef6d73a9c30ccb07f03c62d5d211d13559fdd7703f373f72af6d3c631ecf753451b93737777e82b2fc053ae5cb0ef
|
data/.rubocop.yml
CHANGED
@@ -4,6 +4,11 @@ AllCops:
|
|
4
4
|
Exclude:
|
5
5
|
- "vendor/**/*"
|
6
6
|
|
7
|
+
Layout/MultilineMethodCallIndentation:
|
8
|
+
EnforcedStyle: indented
|
9
|
+
Layout/SpaceInsideBlockBraces:
|
10
|
+
EnforcedStyle: space
|
11
|
+
SpaceBeforeBlockParameters: false
|
7
12
|
Lint/UnderscorePrefixedVariableName:
|
8
13
|
Enabled: false
|
9
14
|
Lint/UnusedMethodArgument:
|
@@ -19,6 +24,9 @@ Metrics/ParameterLists:
|
|
19
24
|
Metrics/MethodLength:
|
20
25
|
Max: 30
|
21
26
|
|
27
|
+
Naming/FileName:
|
28
|
+
Enabled: false
|
29
|
+
|
22
30
|
Style/AsciiComments:
|
23
31
|
Enabled: false
|
24
32
|
Style/HashSyntax:
|
@@ -29,11 +37,11 @@ Style/FrozenStringLiteralComment:
|
|
29
37
|
Enabled: false
|
30
38
|
Style/StringLiterals:
|
31
39
|
EnforcedStyle: double_quotes
|
32
|
-
Style/
|
40
|
+
Style/TrailingCommaInArrayLiteral:
|
33
41
|
Enabled: false
|
34
|
-
Style/
|
42
|
+
Style/TrailingCommaInHashLiteral:
|
35
43
|
Enabled: false
|
36
|
-
Style/
|
44
|
+
Style/TrailingCommaInArguments:
|
37
45
|
Enabled: false
|
38
46
|
Style/Documentation:
|
39
47
|
Enabled: false
|
@@ -41,13 +49,8 @@ Style/WordArray:
|
|
41
49
|
Enabled: false
|
42
50
|
Style/BarePercentLiterals:
|
43
51
|
EnforcedStyle: percent_q
|
44
|
-
Style/SpaceInsideBlockBraces:
|
45
|
-
EnforcedStyle: space
|
46
|
-
SpaceBeforeBlockParameters: false
|
47
52
|
Style/BracesAroundHashParameters:
|
48
53
|
Enabled: false
|
49
|
-
Style/MultilineMethodCallIndentation:
|
50
|
-
EnforcedStyle: indented
|
51
54
|
Style/DoubleNegation:
|
52
55
|
Enabled: false
|
53
56
|
Style/EmptyCaseCondition:
|
data/.travis.yml
CHANGED
@@ -9,13 +9,11 @@ notifications:
|
|
9
9
|
on_failure: always
|
10
10
|
on_start: never
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
gemfile:
|
20
|
-
- Gemfile
|
21
|
-
- gemfiles/fluentd_v0.14.gemfile
|
12
|
+
matrix:
|
13
|
+
include:
|
14
|
+
- rvm: 2.4.5
|
15
|
+
gemfile: Gemfile
|
16
|
+
- rvm: 2.5.5
|
17
|
+
gemfile: Gemfile
|
18
|
+
- rvm: 2.6.2
|
19
|
+
gemfile: Gemfile
|
data/Appraisals
CHANGED
data/README.md
CHANGED
@@ -33,58 +33,69 @@ Or install it yourself as:
|
|
33
33
|
|
34
34
|
The key for part of multiline log.
|
35
35
|
|
36
|
-
**separator** (string)
|
36
|
+
**separator** (string) (optional)
|
37
37
|
|
38
38
|
The separator of lines.
|
39
39
|
Default value is `"\n"`.
|
40
40
|
|
41
|
-
**n\_lines** (integer)
|
41
|
+
**n\_lines** (integer) (optional)
|
42
42
|
|
43
43
|
The number of lines.
|
44
44
|
This is exclusive with `multiline_start_regex`.
|
45
45
|
|
46
|
-
**multiline\_start\_regexp**
|
46
|
+
**multiline\_start\_regexp** (string) (optional)
|
47
47
|
|
48
48
|
The regexp to match beginning of multiline.
|
49
49
|
This is exclusive with `n_lines.`
|
50
50
|
|
51
|
-
**multiline\_end\_regexp**
|
51
|
+
**multiline\_end\_regexp** (string) (optional)
|
52
52
|
|
53
53
|
The regexp to match ending of multiline.
|
54
54
|
This is exclusive with `n_lines.`
|
55
55
|
|
56
|
-
**continuous\_line\_regexp**
|
56
|
+
**continuous\_line\_regexp** (string) (optional)
|
57
57
|
|
58
58
|
The regexp to match continuous lines.
|
59
59
|
This is exclusive with `n_lines.`
|
60
60
|
|
61
|
-
**stream\_identity\_key** (string)
|
61
|
+
**stream\_identity\_key** (string) (optional)
|
62
62
|
|
63
63
|
The key to determine which stream an event belongs to.
|
64
64
|
|
65
|
-
**flush\_interval** (integer)
|
65
|
+
**flush\_interval** (integer) (optional)
|
66
66
|
|
67
67
|
The number of seconds after which the last received event log will be flushed.
|
68
68
|
If specified 0, wait for next line forever.
|
69
69
|
|
70
|
-
**
|
70
|
+
**timeout\_label** (string) (optional)
|
71
|
+
|
72
|
+
The label name to handle events caused by timeout.
|
73
|
+
|
74
|
+
**use\_first\_timestamp** (bool) (optional)
|
71
75
|
|
72
76
|
Use timestamp of first record when buffer is flushed.
|
73
77
|
Default value is `false`.
|
74
78
|
|
75
|
-
**partial\_key** (string)
|
79
|
+
**partial\_key** (string) (optional)
|
76
80
|
|
77
81
|
The field name that is the reference to concatenate records
|
78
82
|
|
79
|
-
**partial\_value** (string)
|
83
|
+
**partial\_value** (string) (optional)
|
80
84
|
|
81
85
|
The value stored in the field specified by partial_key that represent partial log
|
82
86
|
|
83
|
-
**keep\_partial\_key** (bool)
|
87
|
+
**keep\_partial\_key** (bool) (optional)
|
84
88
|
|
85
89
|
If true, keep partial_key in concatenated records
|
86
90
|
Default value is `false`.
|
87
91
|
|
92
|
+
**use\_partial\_metadata** (bool) (optional)
|
93
|
+
|
94
|
+
Use partial metadata to concatenate multiple records
|
95
|
+
|
96
|
+
**keep\_partial\_metadata** (bool) (optional)
|
97
|
+
|
98
|
+
If true, keep partial metadata
|
88
99
|
|
89
100
|
## Usage
|
90
101
|
|
@@ -152,7 +163,7 @@ Handle single line JSON from Docker containers.
|
|
152
163
|
</filter>
|
153
164
|
```
|
154
165
|
|
155
|
-
Handle Docker
|
166
|
+
Handle Docker logs splitted in several parts (using `partial_message`), and do not add new line between parts.
|
156
167
|
|
157
168
|
```aconf
|
158
169
|
<filter>
|
@@ -160,6 +171,18 @@ Handle Docker's `partial_message`.
|
|
160
171
|
key message
|
161
172
|
partial_key partial_message
|
162
173
|
partial_value true
|
174
|
+
separator ""
|
175
|
+
</filter>
|
176
|
+
```
|
177
|
+
|
178
|
+
Handle Docker logs splitted in several parts (using newline detection), and do not add new line between parts (prior to Docker 18.06).
|
179
|
+
|
180
|
+
```aconf
|
181
|
+
<filter **>
|
182
|
+
@type concat
|
183
|
+
key log
|
184
|
+
multiline_end_regexp /\\n$/
|
185
|
+
separator ""
|
163
186
|
</filter>
|
164
187
|
```
|
165
188
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-concat"
|
7
|
-
spec.version = "2.
|
7
|
+
spec.version = "2.4.0"
|
8
8
|
spec.authors = ["Kenji Okimoto"]
|
9
9
|
spec.email = ["okimoto@clear-code.com"]
|
10
10
|
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_runtime_dependency "fluentd", ">= 0.14.0", "< 2"
|
20
|
-
spec.add_development_dependency "bundler"
|
20
|
+
spec.add_development_dependency "bundler"
|
21
21
|
spec.add_development_dependency "rake", "~> 12.0"
|
22
22
|
spec.add_development_dependency "test-unit", ">= 3.1.0"
|
23
23
|
spec.add_development_dependency "test-unit-rr"
|
@@ -32,6 +32,10 @@ module Fluent::Plugin
|
|
32
32
|
config_param :partial_value, :string, default: nil
|
33
33
|
desc "If true, keep partial_key in concatenated records"
|
34
34
|
config_param :keep_partial_key, :bool, default: false
|
35
|
+
desc "Use partial metadata to concatenate multiple records"
|
36
|
+
config_param :use_partial_metadata, :bool, default: false
|
37
|
+
desc "If true, keep partial metadata"
|
38
|
+
config_param :keep_partial_metadata, :bool, default: false
|
35
39
|
|
36
40
|
class TimeoutError < StandardError
|
37
41
|
end
|
@@ -49,12 +53,12 @@ module Fluent::Plugin
|
|
49
53
|
def configure(conf)
|
50
54
|
super
|
51
55
|
|
56
|
+
if @n_lines.nil? && @multiline_start_regexp.nil? && @multiline_end_regexp.nil? && @partial_key.nil? && !@use_partial_metadata
|
57
|
+
raise Fluent::ConfigError, "Either n_lines, multiline_start_regexp, multiline_end_regexp, partial_key or use_partial_metadata is required"
|
58
|
+
end
|
52
59
|
if @n_lines && (@multiline_start_regexp || @multiline_end_regexp)
|
53
60
|
raise Fluent::ConfigError, "n_lines and multiline_start_regexp/multiline_end_regexp are exclusive"
|
54
61
|
end
|
55
|
-
if @n_lines.nil? && @multiline_start_regexp.nil? && @multiline_end_regexp.nil? && @partial_key.nil?
|
56
|
-
raise Fluent::ConfigError, "Either n_lines or multiline_start_regexp or multiline_end_regexp is required"
|
57
|
-
end
|
58
62
|
if @partial_key && @n_lines
|
59
63
|
raise Fluent::ConfigError, "partial_key and n_lines are exclusive"
|
60
64
|
end
|
@@ -64,6 +68,15 @@ module Fluent::Plugin
|
|
64
68
|
if @partial_key && @partial_value.nil?
|
65
69
|
raise Fluent::ConfigError, "partial_value is required when partial_key is specified"
|
66
70
|
end
|
71
|
+
if @use_partial_metadata && @n_lines
|
72
|
+
raise Fluent::ConfigError, "user_partial_metadata and n_lines are exclusive"
|
73
|
+
end
|
74
|
+
if @use_partial_metadata && (@multiline_start_regexp || @multiline_end_regexp)
|
75
|
+
raise Fluent::ConfigError, "user_partial_metadata and multiline_start_regexp/multiline_end_regexp are exclusive"
|
76
|
+
end
|
77
|
+
if @use_partial_metadata && @partial_key
|
78
|
+
raise Fluent::ConfigError, "user_partial_metadata and partial_key are exclusive"
|
79
|
+
end
|
67
80
|
|
68
81
|
@mode = nil
|
69
82
|
case
|
@@ -71,6 +84,8 @@ module Fluent::Plugin
|
|
71
84
|
@mode = :line
|
72
85
|
when @partial_key
|
73
86
|
@mode = :partial
|
87
|
+
when @use_partial_metadata
|
88
|
+
@mode = :partial_metadata
|
74
89
|
when @multiline_start_regexp || @multiline_end_regexp
|
75
90
|
@mode = :regexp
|
76
91
|
if @multiline_start_regexp
|
@@ -108,13 +123,35 @@ module Fluent::Plugin
|
|
108
123
|
new_es.add(time, record)
|
109
124
|
next
|
110
125
|
end
|
126
|
+
if @mode == :partial
|
127
|
+
unless record.key?(@partial_key)
|
128
|
+
new_es.add(time, record)
|
129
|
+
next
|
130
|
+
end
|
131
|
+
end
|
132
|
+
if @mode == :partial_metadata
|
133
|
+
unless record.key?("partial_message")
|
134
|
+
new_es.add(time, record)
|
135
|
+
next
|
136
|
+
end
|
137
|
+
end
|
111
138
|
begin
|
112
139
|
flushed_es = process(tag, time, record)
|
113
140
|
unless flushed_es.empty?
|
114
141
|
flushed_es.each do |_time, new_record|
|
115
142
|
time = _time if @use_first_timestamp
|
116
143
|
merged_record = record.merge(new_record)
|
117
|
-
|
144
|
+
case @mode
|
145
|
+
when :partial
|
146
|
+
merged_record.delete(@partial_key) unless @keep_partial_key
|
147
|
+
when :partial_metadata
|
148
|
+
unless @keep_partial_metadata
|
149
|
+
merged_record.delete("partial_message")
|
150
|
+
merged_record.delete("partial_id")
|
151
|
+
merged_record.delete("partial_ordinal")
|
152
|
+
merged_record.delete("partial_last")
|
153
|
+
end
|
154
|
+
end
|
118
155
|
new_es.add(time, merged_record)
|
119
156
|
end
|
120
157
|
end
|
@@ -136,10 +173,18 @@ module Fluent::Plugin
|
|
136
173
|
end
|
137
174
|
|
138
175
|
def process(tag, time, record)
|
139
|
-
if @
|
140
|
-
|
176
|
+
if @mode == :partial_metadata
|
177
|
+
if @stream_identity_key
|
178
|
+
stream_identity = %Q(#{tag}:#{record[@stream_identity_key]}#{record["partial_id"]})
|
179
|
+
else
|
180
|
+
stream_identity = %Q(#{tag}:#{record["partial_id"]})
|
181
|
+
end
|
141
182
|
else
|
142
|
-
|
183
|
+
if @stream_identity_key
|
184
|
+
stream_identity = "#{tag}:#{record[@stream_identity_key]}"
|
185
|
+
else
|
186
|
+
stream_identity = "#{tag}:default"
|
187
|
+
end
|
143
188
|
end
|
144
189
|
@timeout_map_mutex.synchronize do
|
145
190
|
@timeout_map[stream_identity] = Fluent::Engine.now
|
@@ -149,6 +194,8 @@ module Fluent::Plugin
|
|
149
194
|
process_line(stream_identity, tag, time, record)
|
150
195
|
when :partial
|
151
196
|
process_partial(stream_identity, tag, time, record)
|
197
|
+
when :partial_metadata
|
198
|
+
process_partial_metadata(stream_identity, tag, time, record)
|
152
199
|
when :regexp
|
153
200
|
process_regexp(stream_identity, tag, time, record)
|
154
201
|
end
|
@@ -177,6 +224,18 @@ module Fluent::Plugin
|
|
177
224
|
new_es
|
178
225
|
end
|
179
226
|
|
227
|
+
def process_partial_metadata(stream_identity, tag, time, record)
|
228
|
+
new_es = Fluent::MultiEventStream.new
|
229
|
+
@buffer[stream_identity] << [tag, time, record]
|
230
|
+
if record["partial_last"] == "true"
|
231
|
+
new_time, new_record = flush_buffer(stream_identity)
|
232
|
+
time = new_time if @use_first_timestamp
|
233
|
+
new_record.delete(@partial_key)
|
234
|
+
new_es.add(time, new_record)
|
235
|
+
end
|
236
|
+
new_es
|
237
|
+
end
|
238
|
+
|
180
239
|
def process_regexp(stream_identity, tag, time, record)
|
181
240
|
new_es = Fluent::MultiEventStream.new
|
182
241
|
case
|
@@ -245,7 +304,13 @@ module Fluent::Plugin
|
|
245
304
|
end
|
246
305
|
|
247
306
|
def flush_buffer(stream_identity, new_element = nil)
|
248
|
-
lines = @
|
307
|
+
lines = if @mode == :partial_metadata
|
308
|
+
@buffer[stream_identity]
|
309
|
+
.sort_by {|_tag, _time, record| record["partial_ordinal"].to_i }
|
310
|
+
.map {|_tag, _time, record| record[@key] }
|
311
|
+
else
|
312
|
+
@buffer[stream_identity].map {|_tag, _time, record| record[@key] }
|
313
|
+
end
|
249
314
|
_tag, time, first_record = @buffer[stream_identity].first
|
250
315
|
new_record = {
|
251
316
|
@key => lines.join(@separator)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-concat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenji Okimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -34,16 +34,16 @@ dependencies:
|
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
39
|
+
version: '0'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +118,6 @@ files:
|
|
118
118
|
- README.md
|
119
119
|
- Rakefile
|
120
120
|
- fluent-plugin-concat.gemspec
|
121
|
-
- gemfiles/fluentd_v0.14.gemfile
|
122
121
|
- lib/fluent/plugin/filter_concat.rb
|
123
122
|
homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-concat
|
124
123
|
licenses:
|
@@ -139,8 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
138
|
- !ruby/object:Gem::Version
|
140
139
|
version: '0'
|
141
140
|
requirements: []
|
142
|
-
|
143
|
-
rubygems_version: 2.7.6
|
141
|
+
rubygems_version: 3.0.3
|
144
142
|
signing_key:
|
145
143
|
specification_version: 4
|
146
144
|
summary: Fluentd Filter plugin to concat multiple event messages
|