From 53e2474d0586aabc456d725496c280a5e1bf41be Mon Sep 17 00:00:00 2001 From: Rafay Qayyum Date: Sun, 15 Nov 2026 18:22:20 +0500 Subject: [PATCH] parser_syslog: require the space after VERSION to detect RFC 5424 Signed-off-by: Rafay Qayyum --- lib/fluent/plugin/parser_syslog.rb | 2 +- test/plugin/test_parser_syslog.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/fluent/plugin/parser_syslog.rb b/lib/fluent/plugin/parser_syslog.rb index 52c3b1f066..ad7ff3e083 100644 --- a/lib/fluent/plugin/parser_syslog.rb +++ b/lib/fluent/plugin/parser_syslog.rb @@ -38,7 +38,7 @@ class SyslogParser < Parser \A<(?[0-9]{1,3})\>[1-9]\d{0,2} %s\z EOS - REGEXP_DETECT_RFC5424 = /\A\<[0-9]{1,3}\>[1-9]\d{0,2}/ + REGEXP_DETECT_RFC5424 = /\A\<[0-9]{1,3}\>[1-9]\d{0,2} / RFC3164_WITHOUT_TIME_AND_PRI_REGEXP = /(?[^ ]*) (?[^ :\[]*)(?:\[(?[0-9]+)\])?(?:[^\:]*\:)? *(?.*)$/ RFC3164_CAPTURES = RFC3164_WITHOUT_TIME_AND_PRI_REGEXP.names.freeze diff --git a/test/plugin/test_parser_syslog.rb b/test/plugin/test_parser_syslog.rb index a96dd360ed..a88d924811 100644 --- a/test/plugin/test_parser_syslog.rb +++ b/test/plugin/test_parser_syslog.rb @@ -354,6 +354,23 @@ def test_auto_detects_rfc3164_when_a_later_line_looks_like_rfc5424(parser_engine assert_equal([13, 'web01', 'nginx'], record.values_at('pri', 'host', 'ident')) end + data('regexp' => 'regexp', 'string' => 'string') + def test_auto_detects_rfc3164_with_a_timestamp_starting_with_the_year(parser_engine) + @parser.configure( + 'parser_engine' => parser_engine, + 'message_format' => 'auto', + 'with_priority' => true, + 'time_format' => '%Y-%m-%dT%H:%M:%S%z', + ) + + time = record = nil + @parser.instance.parse('<13>2026-04-25T16:43:29+00:00 web01 nginx: hello') do |t, r| + time, record = t, r + end + assert_equal(event_time('2026-04-25T16:43:29+00:00', format: '%Y-%m-%dT%H:%M:%S%z'), time) + assert_equal([13, 'web01', 'nginx', 'hello'], record.values_at('pri', 'host', 'ident', 'message')) + end + data( 'rfc5424' => ['rfc5424', 'time_format'], 'auto' => ['auto', 'rfc5424_time_format'],