lib/logstash/outputs/http.rb
# This output lets you `PUT` or `POST` events to a
# generic HTTP(S) endpoint
#
# Additionally, you are given the option to customize
# the headers sent as well as basic customization of the
# event json itself.
This output lets you `PUT` or `POST` events to a
generic HTTP(S) endpoint

Additionally, you are given the option to customize
the headers sent as well as basic customization of the
event json itself.
This output lets you ` PUT ` or ` POST ` events to a generic HTTP ( S ) endpoint Additionally you are given the option to customize the headers sent as well as basic customization of the event json itself .
def receive(event)
    return unless output?(event)
    if @mapping
      @evt = Hash.new
      @mapping.each do |k,v|
        @evt[k] = event.sprintf(v)
      end
    else
      @evt = event
    end
    case @http_method
    when "put"
      @request = Net::HTTP::Put.new(@uri.path)
    when "post"
      @request = Net::HTTP::Post.new(@uri.path)
    else
      @logger.error("Unknown verb:", :verb => @http_method)
    end
    if @headers
      @headers.each do |k,v|
        @request.add_field(k, event.sprintf(v))
      end
    end
    @request.add_field("Content-Type", @content_type)
    begin
      @request.body = @evt.to_json
      response = @client.request(@request)
    rescue Exception => e
      @logger.warn("Unhandled exception", :request => @request, :response => @response)
    end
  end
def receive ( event ) return unless output? ( event ) if @mapping @evt = Hash . new @mapping . each do | k , v | @evt [ k ] = event . sprintf ( v ) end else @evt = event end case @http_method when "put" @request = Net :: HTTP :: Put . new ( @uri . path ) when "post" @request = Net :: HTTP :: Post . new ( @uri . path ) else @logger . error ( "Unknown verb:" , :verb => @http_method ) end if @headers @headers . each do | k , v | @request . add_field ( k , event . sprintf ( v ) ) end end @request . add_field ( "Content-Type" , @content_type ) begin @request . body = @evt . to_json response = @client . request ( @request ) rescue Exception => e @logger . warn ( "Unhandled exception" , :request => @request , :response => @response ) end end
This output lets you `PUT` or `POST` events to a
generic HTTP(S) endpoint
This output lets you ` PUT ` or ` POST ` events to a generic HTTP ( S ) endpoint
event
<not_specific>