Class: Fluent::Plugin::UdpInput
- Defined in:
- lib/fluent/plugin/in_udp.rb
Constant Summary
Constants included from Configurable
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary
Attributes included from Fluent::PluginLoggerMixin
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Input
#emit_records, #emit_size, #initialize, #metric_callback, #statistics
Methods included from Fluent::PluginHelper::Mixin
Methods included from Fluent::PluginLoggerMixin
included, #initialize, #terminate
Methods included from Fluent::PluginId
#initialize, #plugin_id, #plugin_id_configured?, #plugin_id_for_test?, #plugin_root_dir, #stop
Methods inherited from Base
#acquire_worker_lock, #after_shutdown, #after_shutdown?, #after_start, #after_started?, #before_shutdown, #before_shutdown?, #called_in_test?, #close, #closed?, #configured?, #context_router, #context_router=, #fluentd_worker_id, #get_lock_path, #has_router?, #initialize, #inspect, #plugin_root_dir, #reloadable_plugin?, #shutdown, #shutdown?, #started?, #stop, #stopped?, #string_safe_encoding, #terminate, #terminated?
Methods included from SystemConfig::Mixin
#system_config, #system_config_override
Methods included from Configurable
#config, #configure_proxy_generate, #configured_section_create, included, #initialize, lookup_type, register_type
Constructor Details
This class inherits a constructor from Fluent::Plugin::Input
Instance Method Details
#configure(conf) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# 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? ⇒ Boolean
64 65 66 |
# File 'lib/fluent/plugin/in_udp.rb', line 64 def multi_workers_ready? true end |
#start ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# 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 |