fluentd 1.10.0-x64-mingw32 → 1.11.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +117 -1
- data/CONTRIBUTING.md +1 -1
- data/README.md +4 -0
- data/docs/SECURITY_AUDIT.pdf +0 -0
- data/lib/fluent/command/debug.rb +1 -0
- data/lib/fluent/command/fluentd.rb +14 -1
- data/lib/fluent/config.rb +1 -0
- data/lib/fluent/daemonizer.rb +88 -0
- data/lib/fluent/log.rb +45 -6
- data/lib/fluent/match.rb +1 -1
- data/lib/fluent/plugin/in_dummy.rb +2 -2
- data/lib/fluent/plugin/in_forward.rb +2 -2
- data/lib/fluent/plugin/in_gc_stat.rb +16 -0
- data/lib/fluent/plugin/in_http.rb +2 -2
- data/lib/fluent/plugin/in_monitor_agent.rb +1 -1
- data/lib/fluent/plugin/in_syslog.rb +4 -4
- data/lib/fluent/plugin/in_tail.rb +3 -3
- data/lib/fluent/plugin/in_tail/position_file.rb +23 -6
- data/lib/fluent/plugin/in_unix.rb +77 -77
- data/lib/fluent/plugin/out_copy.rb +1 -1
- data/lib/fluent/plugin/out_file.rb +1 -1
- data/lib/fluent/plugin/out_forward.rb +23 -18
- data/lib/fluent/plugin/out_forward/load_balancer.rb +1 -1
- data/lib/fluent/plugin/out_http.rb +15 -2
- data/lib/fluent/plugin/parser_multiline.rb +1 -1
- data/lib/fluent/plugin/parser_syslog.rb +216 -55
- data/lib/fluent/plugin_helper/record_accessor.rb +14 -0
- data/lib/fluent/plugin_helper/service_discovery.rb +7 -0
- data/lib/fluent/plugin_helper/service_discovery/manager.rb +8 -0
- data/lib/fluent/plugin_helper/socket.rb +20 -2
- data/lib/fluent/plugin_helper/socket_option.rb +2 -2
- data/lib/fluent/supervisor.rb +21 -9
- data/lib/fluent/system_config.rb +2 -1
- data/lib/fluent/test/filter_test.rb +2 -2
- data/lib/fluent/test/output_test.rb +3 -3
- data/lib/fluent/version.rb +1 -1
- data/test/command/test_fluentd.rb +57 -10
- data/test/config/test_system_config.rb +2 -0
- data/test/plugin/in_tail/test_position_file.rb +24 -0
- data/test/plugin/out_forward/test_load_balancer.rb +46 -0
- data/test/plugin/test_in_gc_stat.rb +24 -1
- data/test/plugin/test_in_syslog.rb +16 -1
- data/test/plugin/test_in_tail.rb +39 -16
- data/test/plugin/test_in_unix.rb +128 -73
- data/test/plugin/test_out_forward.rb +11 -2
- data/test/plugin/test_out_http.rb +38 -0
- data/test/plugin/test_out_null.rb +1 -1
- data/test/plugin/test_output_as_buffered_retries.rb +12 -4
- data/test/plugin/test_output_as_buffered_secondary.rb +9 -1
- data/test/plugin/test_parser_syslog.rb +77 -29
- data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +20 -0
- data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +27 -0
- data/test/plugin_helper/data/cert/cert_chains/cert.pem +40 -0
- data/test/plugin_helper/data/cert/generate_cert.rb +38 -0
- data/test/plugin_helper/http_server/test_app.rb +1 -1
- data/test/plugin_helper/http_server/test_route.rb +1 -1
- data/test/plugin_helper/test_http_server_helper.rb +2 -2
- data/test/plugin_helper/test_record_accessor.rb +41 -0
- data/test/plugin_helper/test_server.rb +1 -1
- data/test/plugin_helper/test_service_discovery.rb +37 -4
- data/test/plugin_helper/test_socket.rb +131 -0
- data/test/test_daemonizer.rb +91 -0
- data/test/test_log.rb +44 -0
- metadata +16 -2
@@ -1056,7 +1056,7 @@ EOL
|
|
1056
1056
|
e = assert_raise Fluent::UnrecoverableError do
|
1057
1057
|
d.instance_start
|
1058
1058
|
end
|
1059
|
-
assert_match(/
|
1059
|
+
assert_match(/failed to establish connection/, e.message)
|
1060
1060
|
end
|
1061
1061
|
end
|
1062
1062
|
|
@@ -1092,7 +1092,7 @@ EOL
|
|
1092
1092
|
d.instance_start
|
1093
1093
|
end
|
1094
1094
|
|
1095
|
-
assert_match(/
|
1095
|
+
assert_match(/failed to establish connection/, e.message)
|
1096
1096
|
end
|
1097
1097
|
end
|
1098
1098
|
|
@@ -1200,6 +1200,15 @@ EOL
|
|
1200
1200
|
end
|
1201
1201
|
end
|
1202
1202
|
|
1203
|
+
test 'create timer of purging obsolete sockets' do
|
1204
|
+
output_conf = CONFIG + %[keepalive true]
|
1205
|
+
d = create_driver(output_conf)
|
1206
|
+
|
1207
|
+
mock(d.instance).timer_execute(:out_forward_heartbeat_request, 1).once
|
1208
|
+
mock(d.instance).timer_execute(:out_forward_keep_alived_socket_watcher, 5).once
|
1209
|
+
d.instance_start
|
1210
|
+
end
|
1211
|
+
|
1203
1212
|
sub_test_case 'with require_ack_response' do
|
1204
1213
|
test 'Create connection per send_data' do
|
1205
1214
|
target_input_driver = create_target_input_driver(conf: TARGET_CONFIG)
|
@@ -80,6 +80,8 @@ class HTTPOutputTest < Test::Unit::TestCase
|
|
80
80
|
req.body.each_line { |l|
|
81
81
|
data << JSON.parse(l)
|
82
82
|
}
|
83
|
+
when 'application/json'
|
84
|
+
data = JSON.parse(req.body)
|
83
85
|
when 'text/plain'
|
84
86
|
# Use single_value in this test
|
85
87
|
req.body.each_line { |line|
|
@@ -181,6 +183,19 @@ class HTTPOutputTest < Test::Unit::TestCase
|
|
181
183
|
assert_not_match(/Status code 503 is going to be removed/, d.instance.log.out.logs.join)
|
182
184
|
end
|
183
185
|
|
186
|
+
# Check if an exception is raised on not JSON format use
|
187
|
+
data('not_json' => 'msgpack')
|
188
|
+
def test_configure_with_json_array_err(format_type)
|
189
|
+
assert_raise(Fluent::ConfigError) do
|
190
|
+
create_driver(config + %[
|
191
|
+
json_array true
|
192
|
+
<format>
|
193
|
+
@type #{format_type}
|
194
|
+
</format>
|
195
|
+
])
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
184
199
|
data('json' => ['json', 'application/x-ndjson'],
|
185
200
|
'ltsv' => ['ltsv', 'text/tab-separated-values'],
|
186
201
|
'msgpack' => ['msgpack', 'application/x-msgpack'],
|
@@ -195,6 +210,14 @@ class HTTPOutputTest < Test::Unit::TestCase
|
|
195
210
|
assert_equal content_type, d.instance.content_type
|
196
211
|
end
|
197
212
|
|
213
|
+
# Check that json_array setting sets content_type = application/json
|
214
|
+
data('json' => 'application/json')
|
215
|
+
def test_configure_content_type_json_array(content_type)
|
216
|
+
d = create_driver(config + "json_array true")
|
217
|
+
|
218
|
+
assert_equal content_type, d.instance.content_type
|
219
|
+
end
|
220
|
+
|
198
221
|
data('PUT' => 'put', 'POST' => 'post')
|
199
222
|
def test_write_with_method(method)
|
200
223
|
d = create_driver(config + "http_method #{method}")
|
@@ -211,6 +234,21 @@ class HTTPOutputTest < Test::Unit::TestCase
|
|
211
234
|
assert_not_empty result.headers
|
212
235
|
end
|
213
236
|
|
237
|
+
# Check that JSON at HTTP request body is valid
|
238
|
+
def test_write_with_json_array_setting
|
239
|
+
d = create_driver(config + "json_array true")
|
240
|
+
d.run(default_tag: 'test.http') do
|
241
|
+
test_events.each { |event|
|
242
|
+
d.feed(event)
|
243
|
+
}
|
244
|
+
end
|
245
|
+
|
246
|
+
result = @@result
|
247
|
+
assert_equal 'application/json', result.content_type
|
248
|
+
assert_equal test_events, result.data
|
249
|
+
assert_not_empty result.headers
|
250
|
+
end
|
251
|
+
|
214
252
|
def test_write_with_single_value_format
|
215
253
|
d = create_driver(config + %[
|
216
254
|
<format>
|
@@ -40,7 +40,7 @@ class NullOutputTest < Test::Unit::TestCase
|
|
40
40
|
assert_equal [], d.instance.chunk_keys
|
41
41
|
end
|
42
42
|
|
43
|
-
test 'writes standard
|
43
|
+
test 'writes standard formatted chunks' do
|
44
44
|
d = create_driver(config_element("ROOT", "", {}, [config_element("buffer")]))
|
45
45
|
t = event_time("2016-05-23 00:22:13 -0800")
|
46
46
|
d.run(default_tag: 'test', flush: true) do
|
@@ -895,17 +895,25 @@ class BufferedOutputRetryTest < Test::Unit::TestCase
|
|
895
895
|
|
896
896
|
@i.flush_thread_wakeup
|
897
897
|
waiting(4){ Thread.pass until @i.write_count > 0 }
|
898
|
+
waiting(4) do
|
899
|
+
state = @i.instance_variable_get(:@output_flush_threads).first
|
900
|
+
state.thread.status == 'sleep'
|
901
|
+
end
|
898
902
|
|
899
|
-
assert
|
900
|
-
assert
|
903
|
+
assert(@i.write_count > 0)
|
904
|
+
assert(@i.num_errors > 0)
|
901
905
|
|
902
906
|
now = @i.next_flush_time
|
903
907
|
Timecop.freeze( now )
|
904
908
|
@i.flush_thread_wakeup
|
905
909
|
waiting(4){ Thread.pass until @i.write_count > 1 }
|
910
|
+
waiting(4) do
|
911
|
+
state = @i.instance_variable_get(:@output_flush_threads).first
|
912
|
+
state.thread.status == 'sleep'
|
913
|
+
end
|
906
914
|
|
907
|
-
assert
|
908
|
-
assert
|
915
|
+
assert(@i.write_count > 1)
|
916
|
+
assert(@i.num_errors > 1)
|
909
917
|
end
|
910
918
|
end
|
911
919
|
end
|
@@ -617,7 +617,15 @@ class BufferedOutputSecondaryTest < Test::Unit::TestCase
|
|
617
617
|
assert{ !chunks[1].empty? }
|
618
618
|
|
619
619
|
30.times do |i| # large enough
|
620
|
-
|
620
|
+
# In https://github.com/fluent/fluentd/blob/c90c024576b3d35f356a55fd33d1232947114a9a/lib/fluent/plugin_helper/retry_state.rb
|
621
|
+
# @timeout_at is 2016-04-13 18:34:31, @next_time must be less than 2016-04-13 18:34:30
|
622
|
+
#
|
623
|
+
# first_failure + 60 * 0.8 + 2 # => 2016-04-13 18:34:21
|
624
|
+
# @next_time is not added by 1, but by randomize(@retry_wait) https://github.com/fluent/fluentd/blob/c90c024576b3d35f356a55fd33d1232947114a9a/lib/fluent/plugin_helper/retry_state.rb#L196
|
625
|
+
# current_time(=Time.now) + randomize(@retry_wait) < @timeout_at
|
626
|
+
# (2016-04-13 18:34:21 + 6) + 3 < 2016-04-13 18:34:31
|
627
|
+
# So, current_time must be at most 6
|
628
|
+
now = first_failure + 60 * 0.8 + 2 + [i, 6].min
|
621
629
|
Timecop.freeze( now )
|
622
630
|
@i.flush_thread_wakeup
|
623
631
|
|
@@ -35,8 +35,9 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
35
35
|
assert_equal('%b %d %M:%S:%H', @parser.instance.patterns['time_format'])
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
39
|
+
def test_parse_with_time_format2(param)
|
40
|
+
@parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'parser_type' => param)
|
40
41
|
@parser.instance.parse('2020-03-03T10:14:29Z 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
|
41
42
|
assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
|
42
43
|
assert_equal(@expected, record)
|
@@ -73,6 +74,16 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
73
74
|
assert_equal("%b %d %H:%M:%S", @parser.instance.patterns['time_format'])
|
74
75
|
end
|
75
76
|
|
77
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
78
|
+
def test_parse_rfc5452_with_priority(param)
|
79
|
+
@parser.configure('with_priority' => true, 'parser_type' => param, 'message_format' => 'rfc5424')
|
80
|
+
@parser.instance.parse('<30>1 2020-03-31T20:32:54Z myhostname 02abaf0687f5 10339 02abaf0687f5 - method=POST db=0.00') do |time, record|
|
81
|
+
assert_equal(event_time('2020-03-31T20:32:54Z', format: '%Y-%m-%dT%H:%M:%S%z'), time)
|
82
|
+
expected = { 'extradata' => '-', 'host' => 'myhostname', 'ident' => '02abaf0687f5', 'message' => 'method=POST db=0.00', 'msgid' => '02abaf0687f5', 'pid' => '10339', 'pri' => 30 }
|
83
|
+
assert_equal(expected, record)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
76
87
|
data('regexp' => 'regexp', 'string' => 'string')
|
77
88
|
def test_parse_with_empty_priority(param)
|
78
89
|
@parser.configure('with_priority' => true, 'parser_type' => param)
|
@@ -188,11 +199,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
188
199
|
end
|
189
200
|
|
190
201
|
class TestRFC5424Regexp < self
|
191
|
-
|
202
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
203
|
+
def test_parse_with_rfc5424_message(param)
|
192
204
|
@parser.configure(
|
193
205
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
194
206
|
'message_format' => 'rfc5424',
|
195
207
|
'with_priority' => true,
|
208
|
+
'parser_type' => param
|
196
209
|
)
|
197
210
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
|
198
211
|
@parser.instance.parse(text) do |time, record|
|
@@ -205,11 +218,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
205
218
|
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
206
219
|
end
|
207
220
|
|
208
|
-
|
221
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
222
|
+
def test_parse_with_rfc5424_message_trailing_eol(param)
|
209
223
|
@parser.configure(
|
210
224
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
211
225
|
'message_format' => 'rfc5424',
|
212
226
|
'with_priority' => true,
|
227
|
+
'parser_type' => param
|
213
228
|
)
|
214
229
|
text = "<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!\n"
|
215
230
|
@parser.instance.parse(text) do |time, record|
|
@@ -222,11 +237,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
222
237
|
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
223
238
|
end
|
224
239
|
|
225
|
-
|
240
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
241
|
+
def test_parse_with_rfc5424_multiline_message(param)
|
226
242
|
@parser.configure(
|
227
243
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
228
244
|
'message_format' => 'rfc5424',
|
229
245
|
'with_priority' => true,
|
246
|
+
'parser_type' => param
|
230
247
|
)
|
231
248
|
text = "<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi,\nfrom\nFluentd!"
|
232
249
|
@parser.instance.parse(text) do |time, record|
|
@@ -239,10 +256,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
239
256
|
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
240
257
|
end
|
241
258
|
|
242
|
-
|
259
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
260
|
+
def test_parse_with_rfc5424_message_and_without_priority(param)
|
243
261
|
@parser.configure(
|
244
262
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
245
263
|
'message_format' => 'rfc5424',
|
264
|
+
'parser_type' => param
|
246
265
|
)
|
247
266
|
text = '2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
|
248
267
|
@parser.instance.parse(text) do |time, record|
|
@@ -255,10 +274,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
255
274
|
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
256
275
|
end
|
257
276
|
|
258
|
-
|
277
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
278
|
+
def test_parse_with_rfc5424_empty_message_and_without_priority(param)
|
259
279
|
@parser.configure(
|
260
280
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
261
281
|
'message_format' => 'rfc5424',
|
282
|
+
'parser_type' => param
|
262
283
|
)
|
263
284
|
text = '2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - -'
|
264
285
|
@parser.instance.parse(text) do |time, record|
|
@@ -271,10 +292,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
271
292
|
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
272
293
|
end
|
273
294
|
|
274
|
-
|
295
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
296
|
+
def test_parse_with_rfc5424_message_without_time_format(param)
|
275
297
|
@parser.configure(
|
276
298
|
'message_format' => 'rfc5424',
|
277
299
|
'with_priority' => true,
|
300
|
+
'parser_type' => param
|
278
301
|
)
|
279
302
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
|
280
303
|
@parser.instance.parse(text) do |time, record|
|
@@ -286,10 +309,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
286
309
|
end
|
287
310
|
end
|
288
311
|
|
289
|
-
|
312
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
313
|
+
def test_parse_with_rfc5424_message_with_priority_and_pid(param)
|
290
314
|
@parser.configure(
|
291
315
|
'message_format' => 'rfc5424',
|
292
316
|
'with_priority' => true,
|
317
|
+
'parser_type' => param
|
293
318
|
)
|
294
319
|
text = '<28>1 2018-09-26T15:54:26.620412+09:00 machine minissdpd 1298 - - peer 192.168.0.5:50123 is not from a LAN'
|
295
320
|
@parser.instance.parse(text) do |time, record|
|
@@ -301,11 +326,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
301
326
|
end
|
302
327
|
end
|
303
328
|
|
304
|
-
|
329
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
330
|
+
def test_parse_with_rfc5424_structured_message(param)
|
305
331
|
@parser.configure(
|
306
332
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
307
333
|
'message_format' => 'rfc5424',
|
308
334
|
'with_priority' => true,
|
335
|
+
'parser_type' => param
|
309
336
|
)
|
310
337
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] [Hi] from Fluentd!'
|
311
338
|
@parser.instance.parse(text) do |time, record|
|
@@ -318,11 +345,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
318
345
|
end
|
319
346
|
end
|
320
347
|
|
321
|
-
|
348
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
349
|
+
def test_parse_with_rfc5424_multiple_structured_message(param)
|
322
350
|
@parser.configure(
|
323
351
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
324
352
|
'message_format' => 'rfc5424',
|
325
353
|
'with_priority' => true,
|
354
|
+
'parser_type' => param
|
326
355
|
)
|
327
356
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"][exampleSDID@20224 class="high"] Hi, from Fluentd!'
|
328
357
|
@parser.instance.parse(text) do |time, record|
|
@@ -335,11 +364,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
335
364
|
end
|
336
365
|
end
|
337
366
|
|
338
|
-
|
367
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
368
|
+
def test_parse_with_rfc5424_message_includes_right_bracket(param)
|
339
369
|
@parser.configure(
|
340
370
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
341
371
|
'message_format' => 'rfc5424',
|
342
372
|
'with_priority' => true,
|
373
|
+
'parser_type' => param
|
343
374
|
)
|
344
375
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] [Hi] from Fluentd]!'
|
345
376
|
@parser.instance.parse(text) do |time, record|
|
@@ -352,11 +383,13 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
352
383
|
end
|
353
384
|
end
|
354
385
|
|
355
|
-
|
386
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
387
|
+
def test_parse_with_rfc5424_empty_message(param)
|
356
388
|
@parser.configure(
|
357
389
|
'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
|
358
390
|
'message_format' => 'rfc5424',
|
359
391
|
'with_priority' => true,
|
392
|
+
'parser_type' => param
|
360
393
|
)
|
361
394
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"]'
|
362
395
|
@parser.instance.parse(text) do |time, record|
|
@@ -369,10 +402,35 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
369
402
|
end
|
370
403
|
end
|
371
404
|
|
372
|
-
|
405
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
406
|
+
def test_parse_with_rfc5424_space_empty_message(param)
|
407
|
+
@parser.configure(
|
408
|
+
'message_format' => 'rfc5424',
|
409
|
+
'with_priority' => true,
|
410
|
+
'parser_type' => param
|
411
|
+
)
|
412
|
+
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] '
|
413
|
+
@parser.instance.parse(text) do |time, record|
|
414
|
+
if param == 'string'
|
415
|
+
assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
|
416
|
+
assert_equal "11111", record["pid"]
|
417
|
+
assert_equal "ID24224", record["msgid"]
|
418
|
+
assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
|
419
|
+
record["extradata"]
|
420
|
+
assert_equal '', record["message"]
|
421
|
+
else
|
422
|
+
assert_nil time
|
423
|
+
assert_nil record
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
429
|
+
def test_parse_with_rfc5424_message_without_subseconds(param)
|
373
430
|
@parser.configure(
|
374
431
|
'message_format' => 'rfc5424',
|
375
432
|
'with_priority' => true,
|
433
|
+
'parser_type' => param
|
376
434
|
)
|
377
435
|
text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
|
378
436
|
@parser.instance.parse(text) do |time, record|
|
@@ -384,10 +442,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
384
442
|
end
|
385
443
|
end
|
386
444
|
|
387
|
-
|
445
|
+
data('regexp' => 'regexp', 'string' => 'string')
|
446
|
+
def test_parse_with_rfc5424_message_both_timestamp(param)
|
388
447
|
@parser.configure(
|
389
448
|
'message_format' => 'rfc5424',
|
390
449
|
'with_priority' => true,
|
450
|
+
'parser_type' => param
|
391
451
|
)
|
392
452
|
text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
|
393
453
|
@parser.instance.parse(text) do |time, record|
|
@@ -421,7 +481,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
421
481
|
assert_equal(event_time("Feb 28 00:00:12", format: '%b %d %M:%S:%H'), time)
|
422
482
|
assert_equal(@expected, record)
|
423
483
|
end
|
424
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
425
484
|
end
|
426
485
|
|
427
486
|
data('regexp' => 'regexp', 'string' => 'string')
|
@@ -437,7 +496,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
437
496
|
assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
|
438
497
|
assert_equal(@expected.merge('pri' => 6), record)
|
439
498
|
end
|
440
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
441
499
|
end
|
442
500
|
|
443
501
|
data('regexp' => 'regexp', 'string' => 'string')
|
@@ -454,9 +512,9 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
454
512
|
assert_equal "-", record["pid"]
|
455
513
|
assert_equal "-", record["msgid"]
|
456
514
|
assert_equal "-", record["extradata"]
|
515
|
+
assert_equal 16, record["pri"]
|
457
516
|
assert_equal "Hi, from Fluentd!", record["message"]
|
458
517
|
end
|
459
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
460
518
|
end
|
461
519
|
|
462
520
|
data('regexp' => 'regexp', 'string' => 'string')
|
@@ -476,7 +534,7 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
476
534
|
record["extradata"]
|
477
535
|
assert_equal "Hi, from Fluentd!", record["message"]
|
478
536
|
end
|
479
|
-
|
537
|
+
end
|
480
538
|
|
481
539
|
data('regexp' => 'regexp', 'string' => 'string')
|
482
540
|
def test_parse_with_both_message_type(param)
|
@@ -492,7 +550,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
492
550
|
assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
|
493
551
|
assert_equal(@expected.merge('pri' => 1), record)
|
494
552
|
end
|
495
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
496
553
|
|
497
554
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
|
498
555
|
@parser.instance.parse(text) do |time, record|
|
@@ -503,21 +560,18 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
503
560
|
record["extradata"]
|
504
561
|
assert_equal "Hi, from Fluentd!", record["message"]
|
505
562
|
end
|
506
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
507
563
|
|
508
564
|
text = '<1>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test 2>1'
|
509
565
|
@parser.instance.parse(text) do |time, record|
|
510
566
|
assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
|
511
567
|
assert_equal(@expected.merge('pri' => 1, 'message'=> '[error] Syslog test 2>1'), record)
|
512
568
|
end
|
513
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
514
569
|
|
515
570
|
text = '<1>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
|
516
571
|
@parser.instance.parse(text) do |time, record|
|
517
572
|
assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
|
518
573
|
assert_equal(@expected.merge('pri' => 1), record)
|
519
574
|
end
|
520
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
521
575
|
|
522
576
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
|
523
577
|
@parser.instance.parse(text) do |time, record|
|
@@ -527,7 +581,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
527
581
|
assert_equal "-", record["extradata"]
|
528
582
|
assert_equal "Hi, from Fluentd!", record["message"]
|
529
583
|
end
|
530
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
531
584
|
end
|
532
585
|
|
533
586
|
data('regexp' => 'regexp', 'string' => 'string')
|
@@ -544,7 +597,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
544
597
|
assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
|
545
598
|
assert_equal(@expected.merge('pri' => 6), record)
|
546
599
|
end
|
547
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
548
600
|
|
549
601
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
|
550
602
|
@parser.instance.parse(text) do |time, record|
|
@@ -555,14 +607,12 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
555
607
|
record["extradata"]
|
556
608
|
assert_equal "Hi, from Fluentd!", record["message"]
|
557
609
|
end
|
558
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
559
610
|
|
560
611
|
text = '<16>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
|
561
612
|
@parser.instance.parse(text) do |time, record|
|
562
613
|
assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
|
563
614
|
assert_equal(@expected.merge('pri' => 16), record)
|
564
615
|
end
|
565
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
566
616
|
|
567
617
|
text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
|
568
618
|
@parser.instance.parse(text) do |time, record|
|
@@ -572,7 +622,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
572
622
|
assert_equal "-", record["extradata"]
|
573
623
|
assert_equal "Hi, from Fluentd!", record["message"]
|
574
624
|
end
|
575
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
576
625
|
|
577
626
|
text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd without subseconds!'
|
578
627
|
@parser.instance.parse(text) do |time, record|
|
@@ -582,7 +631,6 @@ class SyslogParserTest < ::Test::Unit::TestCase
|
|
582
631
|
assert_equal "-", record["extradata"]
|
583
632
|
assert_equal "Hi, from Fluentd without subseconds!", record["message"]
|
584
633
|
end
|
585
|
-
assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
|
586
634
|
end
|
587
635
|
end
|
588
636
|
end
|