fluent / fluentd

Fluentd: Unified Logging Layer (project under CNCF)
https://www.fluentd.org
Apache License 2.0
12.85k stars 1.34k forks source link

Multicast support in UDP input #4286

Open monai opened 1 year ago

monai commented 1 year ago

Is your feature request related to a problem? Please describe.

UDP input supports only unicast connections.

Describe the solution you'd like

Add a group parameter to the UDP input plugin configuration, e.g.:

desc 'The multicast group address to join to.'
config_param :group, :string, default: nil

If the user provides the value and it is a valid multicast IP address, join the socket to the multicast group of that address.

Describe alternatives you've considered

I cloned builtin in_udp.rb and added the necessary code:

def multi_workers_ready?
  false
end

def start
  super

  log.info "listening udp socket", bind: @bind, port: @port
  server = 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|
    # ...
  end

  @membership = IPAddr.new(@group).hton + IPAddr.new(@bind).hton
  sock = server.instance_variable_get(:@sock)
  sock.setsockopt(:IPPROTO_IP, :IP_ADD_MEMBERSHIP, @membership)
end

Additional context

The difference between unicast and multicast is in the lower protocol, IP, and is taken care of by the network infrastructure. The rest from the user perspective is the same; therefore, I think multicast support should be an option in the built-in UDP input plugin.

Athishpranav2003 commented 1 day ago

I can probably pick this up @daipom I am looking at Webrick implementation for more clarification