fluent-plugin-concat 2.0.1 → 2.1.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/NEWS.md +4 -0
- data/README.md +34 -0
- data/fluent-plugin-concat.gemspec +1 -1
- data/lib/fluent/plugin/filter_concat.rb +62 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dd0443193203c8fba9648470a1deca9cd5f66a3
|
4
|
+
data.tar.gz: b6a9917305e5a1bfe26a95dae7e3902743814f55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61803699c453e5f67fb7e44b6f5b50c225319f1389f63a85e77dd63dd44f49ca4b157c93d27c6e7dfe9937f1eef6f57419d94e88969ebbb4d53f4a736819fcc2
|
7
|
+
data.tar.gz: 50411a7ffd2b30f774b8d0556ff5f6fe2465a3620b1ea83b0bf7544a70a80004c51a3fd44ceec2bd72a84fbfe9c84b82e99e8e7a77cf2d8fc92ebddcbf7a67e4
|
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,13 @@
|
|
4
4
|
|
5
5
|
Fluentd Filter plugin to concatenate multiline log separated in multiple events.
|
6
6
|
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
| fluent-plugin-concat | fluentd | ruby |
|
10
|
+
|----------------------|------------|--------|
|
11
|
+
| >= 2.0.0 | >= v0.14.0 | >= 2.1 |
|
12
|
+
| < 2.0.0 | >= v0.12.0 | >= 1.9 |
|
13
|
+
|
7
14
|
## Installation
|
8
15
|
|
9
16
|
Add this line to your application's Gemfile:
|
@@ -45,6 +52,10 @@ This is exclusive with `n_lines.`
|
|
45
52
|
|
46
53
|
The regexp to match ending of multiline.
|
47
54
|
|
55
|
+
**continuous\_line_\_regexp**
|
56
|
+
|
57
|
+
The regexp to match continuous lines.
|
58
|
+
|
48
59
|
**stream\_identity\_key**
|
49
60
|
|
50
61
|
The key to determine which stream an event belongs to.
|
@@ -91,6 +102,29 @@ You can handle timeout events and remaining buffers on shutdown this plugin.
|
|
91
102
|
</label>
|
92
103
|
```
|
93
104
|
|
105
|
+
Handle timeout log lines the same as normal logs.
|
106
|
+
|
107
|
+
```aconf
|
108
|
+
<filter **>
|
109
|
+
@type concat
|
110
|
+
key message
|
111
|
+
multiline_start_regexp /^Start/
|
112
|
+
flush_interval 5
|
113
|
+
timeout_label @NORMAL
|
114
|
+
</filter>
|
115
|
+
|
116
|
+
<match **>
|
117
|
+
@type relabel
|
118
|
+
@label @NORMAL
|
119
|
+
</match>
|
120
|
+
|
121
|
+
<label @NORMAL>
|
122
|
+
<match **>
|
123
|
+
@type stdout
|
124
|
+
</match>
|
125
|
+
</label>
|
126
|
+
```
|
127
|
+
|
94
128
|
## Contributing
|
95
129
|
|
96
130
|
1. Fork it
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "fluent/plugin/filter"
|
2
2
|
|
3
3
|
module Fluent::Plugin
|
4
4
|
class ConcatFilter < Filter
|
@@ -16,6 +16,8 @@ module Fluent::Plugin
|
|
16
16
|
config_param :multiline_start_regexp, :string, default: nil
|
17
17
|
desc "The regexp to match ending of multiline"
|
18
18
|
config_param :multiline_end_regexp, :string, default: nil
|
19
|
+
desc "The regexp to match continuous lines"
|
20
|
+
config_param :continuous_line_regexp, :string, default: nil
|
19
21
|
desc "The key to determine which stream an event belongs to"
|
20
22
|
config_param :stream_identity_key, :string, default: nil
|
21
23
|
desc "The interval between data flushes, 0 means disable timeout"
|
@@ -55,6 +57,9 @@ module Fluent::Plugin
|
|
55
57
|
if @multiline_end_regexp
|
56
58
|
@multiline_end_regexp = Regexp.compile(@multiline_end_regexp[1..-2])
|
57
59
|
end
|
60
|
+
if @continuous_line_regexp
|
61
|
+
@continuous_line_regexp = Regexp.compile(@continuous_line_regexp[1..-2])
|
62
|
+
end
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
@@ -101,7 +106,6 @@ module Fluent::Plugin
|
|
101
106
|
end
|
102
107
|
|
103
108
|
def process(tag, time, record)
|
104
|
-
new_es = Fluent::MultiEventStream.new
|
105
109
|
if @stream_identity_key
|
106
110
|
stream_identity = "#{tag}:#{record[@stream_identity_key]}"
|
107
111
|
else
|
@@ -110,47 +114,64 @@ module Fluent::Plugin
|
|
110
114
|
@timeout_map[stream_identity] = Fluent::Engine.now
|
111
115
|
case @mode
|
112
116
|
when :line
|
113
|
-
|
114
|
-
if @buffer[stream_identity].size >= @n_lines
|
115
|
-
new_time, new_record = flush_buffer(stream_identity)
|
116
|
-
time = new_time if @use_first_timestamp
|
117
|
-
new_es.add(time, new_record)
|
118
|
-
return new_es
|
119
|
-
end
|
117
|
+
process_line(stream_identity, tag, time, record)
|
120
118
|
when :regexp
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
119
|
+
process_regexp(stream_identity, tag, time, record)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def process_line(stream_identity, tag, time, record)
|
124
|
+
new_es = Fluent::MultiEventStream.new
|
125
|
+
@buffer[stream_identity] << [tag, time, record]
|
126
|
+
if @buffer[stream_identity].size >= @n_lines
|
127
|
+
new_time, new_record = flush_buffer(stream_identity)
|
128
|
+
time = new_time if @use_first_timestamp
|
129
|
+
new_es.add(time, new_record)
|
130
|
+
end
|
131
|
+
new_es
|
132
|
+
end
|
133
|
+
|
134
|
+
def process_regexp(stream_identity, tag, time, record)
|
135
|
+
new_es = Fluent::MultiEventStream.new
|
136
|
+
case
|
137
|
+
when firstline?(record[@key])
|
138
|
+
if @buffer[stream_identity].empty?
|
139
|
+
@buffer[stream_identity] << [tag, time, record]
|
140
|
+
if lastline?(record[@key])
|
141
|
+
new_time, new_record = flush_buffer(stream_identity)
|
132
142
|
time = new_time if @use_first_timestamp
|
133
143
|
new_es.add(time, new_record)
|
134
|
-
if lastline?(record[@key])
|
135
|
-
new_time, new_record = flush_buffer(stream_identity)
|
136
|
-
time = new_time if @use_first_timestamp
|
137
|
-
new_es.add(time, new_record)
|
138
|
-
end
|
139
|
-
return new_es
|
140
144
|
end
|
141
|
-
|
142
|
-
|
143
|
-
new_time, new_record = flush_buffer(stream_identity)
|
145
|
+
else
|
146
|
+
new_time, new_record = flush_buffer(stream_identity, [tag, time, record])
|
144
147
|
time = new_time if @use_first_timestamp
|
145
148
|
new_es.add(time, new_record)
|
149
|
+
if lastline?(record[@key])
|
150
|
+
new_time, new_record = flush_buffer(stream_identity)
|
151
|
+
time = new_time if @use_first_timestamp
|
152
|
+
new_es.add(time, new_record)
|
153
|
+
end
|
154
|
+
return new_es
|
155
|
+
end
|
156
|
+
when lastline?(record[@key])
|
157
|
+
@buffer[stream_identity] << [tag, time, record]
|
158
|
+
new_time, new_record = flush_buffer(stream_identity)
|
159
|
+
time = new_time if @use_first_timestamp
|
160
|
+
new_es.add(time, new_record)
|
161
|
+
return new_es
|
162
|
+
else
|
163
|
+
if @buffer[stream_identity].empty?
|
164
|
+
new_es.add(time, record)
|
146
165
|
return new_es
|
147
166
|
else
|
148
|
-
if @
|
149
|
-
new_es.add(time, record)
|
150
|
-
return new_es
|
151
|
-
else
|
167
|
+
if continuous_line?(record[@key])
|
152
168
|
# Continuation of the previous line
|
153
169
|
@buffer[stream_identity] << [tag, time, record]
|
170
|
+
else
|
171
|
+
new_time, new_record = flush_buffer(stream_identity)
|
172
|
+
time = new_time if @use_first_timestamp
|
173
|
+
new_es.add(time, new_record)
|
174
|
+
new_es.add(time, record)
|
154
175
|
end
|
155
176
|
end
|
156
177
|
end
|
@@ -165,6 +186,14 @@ module Fluent::Plugin
|
|
165
186
|
@multiline_end_regexp && !!@multiline_end_regexp.match(text)
|
166
187
|
end
|
167
188
|
|
189
|
+
def continuous_line?(text)
|
190
|
+
if @continuous_line_regexp
|
191
|
+
!!@continuous_line_regexp.match(text)
|
192
|
+
else
|
193
|
+
true
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
168
197
|
def flush_buffer(stream_identity, new_element = nil)
|
169
198
|
lines = @buffer[stream_identity].map {|_tag, _time, record| record[@key] }
|
170
199
|
_tag, time, first_record = @buffer[stream_identity].first
|
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.0
|
4
|
+
version: 2.1.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: 2017-
|
11
|
+
date: 2017-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|