Sha256: 34f6402388ec6c946a1ad3443d6265b82813181464bdf1c9a77772e84a5c2a65

Contents?: true

Size: 800 Bytes

Versions: 5

Compression:

Stored size: 800 Bytes

Contents

# encoding: utf-8
require "logstash/outputs/base"
require "logstash/namespace"
require "socket"

# Send events over UDP
#
# Keep in mind that UDP will lose messages.
class LogStash::Outputs::UDP < LogStash::Outputs::Base
  config_name "udp"
  
  default :codec, "json"

  # The address to send messages to
  config :host, :validate => :string, :required => true

  # The port to send messages on
  config :port, :validate => :number, :required => true

  public
  def register
    @socket = UDPSocket.new
    @codec.on_event do |event, payload|
      @socket.send(payload, 0, @host, @port)
    end
  end

  def receive(event)
    return unless output?(event)
    if event == LogStash::SHUTDOWN
      finished
      return
    end
    @codec.encode(event)
  end

end # class LogStash::Outputs::Stdout

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
logstash-output-udp-1.1.0 lib/logstash/outputs/udp.rb
logstash-output-udp-1.0.0 lib/logstash/outputs/udp.rb
logstash-output-udp-0.1.5 lib/logstash/outputs/udp.rb
logstash-output-udp-0.1.4 lib/logstash/outputs/udp.rb
logstash-output-udp-0.1.3 lib/logstash/outputs/udp.rb