diff --git a/lib/fluent/plugin/in_syslog.rb b/lib/fluent/plugin/in_syslog.rb index bb46209294..dfb26ef8f2 100644 --- a/lib/fluent/plugin/in_syslog.rb +++ b/lib/fluent/plugin/in_syslog.rb @@ -85,15 +85,16 @@ class SyslogInput < Input config_param :source_hostname_key, :string, default: nil desc 'The field name of source address of sender.' config_param :source_address_key, :string, default: nil - desc 'The field name of the priority.' config_param :priority_key, :string, default: nil desc 'The field name of the facility.' config_param :facility_key, :string, default: nil - config_param :blocking_timeout, :time, default: 0.5 + desc "The max bytes of message" config_param :message_length_limit, :size, default: 2048 + config_param :blocking_timeout, :time, default: 0.5 + config_section :parse do config_set_default :@type, DEFAULT_PARSER config_param :with_priority, :bool, default: true diff --git a/lib/fluent/plugin/in_udp.rb b/lib/fluent/plugin/in_udp.rb index 86f397e2b2..df2c8ad0cb 100644 --- a/lib/fluent/plugin/in_udp.rb +++ b/lib/fluent/plugin/in_udp.rb @@ -34,7 +34,10 @@ class UdpInput < Input desc "The field name of the client's hostname." config_param :source_hostname_key, :string, default: nil - config_param :body_size_limit, :size, default: 4096 + desc "Deprecated parameter. Use message_length_limit instead" + config_param :body_size_limit, :size, default: nil, deprecated: "use message_length_limit instead." + desc "The max bytes of message" + config_param :message_length_limit, :size, default: 4096 config_param :blocking_timeout, :time, default: 0.5 @@ -43,6 +46,7 @@ def configure(conf) super @_event_loop_blocking_timeout = @blocking_timeout @source_hostname_key ||= @source_host_key if @source_host_key + @message_length_limit = @body_size_limit if @body_size_limit @parser = parser_create end @@ -55,7 +59,7 @@ def start super log.info "listening udp socket", bind: @bind, port: @port - server_create(:in_udp_server, @port, proto: :udp, bind: @bind, max_bytes: @body_size_limit) do |data, sock| + server_create(:in_udp_server, @port, proto: :udp, bind: @bind, max_bytes: @message_length_limit) do |data, sock| data.chomp! begin @parser.parse(data) do |time, record| diff --git a/test/plugin/test_in_udp.rb b/test/plugin/test_in_udp.rb index d74588b77e..d18dfb012c 100755 --- a/test/plugin/test_in_udp.rb +++ b/test/plugin/test_in_udp.rb @@ -54,7 +54,7 @@ def create_udp_socket(host, port) d = create_driver(conf) assert_equal PORT, d.instance.port assert_equal bind, d.instance.bind - assert_equal 4096, d.instance.body_size_limit + assert_equal 4096, d.instance.message_length_limit end data( @@ -86,6 +86,16 @@ def create_udp_socket(host, port) end end + data( + 'message_length_limit' => 'message_length_limit 2048', + 'body_size_limit' => 'body_size_limit 2048' + ) + test 'message_length_limit/body_size_limit compatibility' do |param| + + d = create_driver(CONFIG + param) + assert_equal 2048, d.instance.message_length_limit + end + data( 'none' => { 'format' => 'none',