Sha256: 8562627603862f94c51521bd5a4d6196789cf4ffca6e2eb13209ae6abe7d4f92

Contents?: true

Size: 807 Bytes

Versions: 3

Compression:

Stored size: 807 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"
  milestone 1
  
  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 |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

3 entries across 3 versions & 2 rubygems

Version Path
logstash-output-udp-0.1.1 lib/logstash/outputs/udp.rb
logstash-output-udp-0.1.0 lib/logstash/outputs/udp.rb
logstash-lib-1.3.2 lib/logstash/outputs/udp.rb