Input-gelf-plugin wrong SOURCE_HOST_FIELD


(Aborche) #1

When gelf plugin receives a message, SOURCE_HOST_FIELD filled with logstash listen address, instead of connected client address. And all incoming log records contains "0.0.0.0" instead real client ip.
Value for SOURCE_HOST_FIELD must be client.peeraddr[2] ?

logstash-plugins/logstash-input-gelf/lib/logstash/inputs)/gelf.rb

    begin  # Create event
      event = LogStash::Event.new(jsonObj)
      **event.set(SOURCE_HOST_FIELD, host.force_encoding("UTF-8"))**
      if event.get("timestamp").is_a?(Numeric)
        event.set("timestamp", LogStash::Timestamp.at(event.get("timestamp")))
        event.remove("timestamp")
      end
      remap_gelf(event) if @remap
      strip_leading_underscore(event) if @strip_leading_underscore
      decorate(event)
      output_queue << event
    rescue => ex
      @logger.warn("Gelf (tcp): failed to create event from json object. Skipping: " + jsonObj.to_s, :exception => ex, :backtrace => ex.backtrace)
    end