class Fluent::Plugin::UdpInput
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
Fluent::Plugin::Input#configure
# File lib/fluent/plugin/in_udp.rb, line 50 def configure(conf) compat_parameters_convert(conf, :parser) parser_config = conf.elements('parse').first unless parser_config raise Fluent::ConfigError, "<parse> section is required." end 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(conf: parser_config) end
multi_workers_ready?()
click to toggle source
# File lib/fluent/plugin/in_udp.rb, line 64 def multi_workers_ready? true end
start()
click to toggle source
Calls superclass method
Fluent::Compat::Input#start
# File lib/fluent/plugin/in_udp.rb, line 68 def start super log.info "listening udp socket", bind: @bind, port: @port server_create(:in_udp_server, @port, proto: :udp, bind: @bind, resolve_name: !!@source_hostname_key, max_bytes: @message_length_limit, receive_buffer_size: @receive_buffer_size) do |data, sock| data.chomp! if @remove_newline begin @parser.parse(data) do |time, record| unless time && record log.warn "pattern not matched", data: data next end tag = extract_tag_from_record(record) tag ||= @tag time ||= extract_time_from_record(record) || Fluent::EventTime.now record[@source_address_key] = sock.remote_addr if @source_address_key record[@source_hostname_key] = sock.remote_host if @source_hostname_key router.emit(tag, time, record) end end end end