Sha256: 184630db4a150f9ba3aa298735f1fba6b168ebf55aa80e395c68e020d7d8e4f9
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
# encoding: utf-8 require "logstash/outputs/base" require "logstash/namespace" require "logstash/json" class LogStash::Outputs::Https < LogStash::Outputs::Base config_name "https" config :headers, :validate => :hash config :url, :validate => :string, :required => :true config :verb, :validate => ["put", "post"], :default => "post", :required => :true public def register require "net/http" require "uri" @uri = URI.parse(@url) @agent = Net::HTTP.new(@uri.host, @uri.port) @agent.use_ssl = true @agent.verify_mode = OpenSSL::SSL::VERIFY_NONE end public def receive(event) return unless output?(event) begin case @verb when "put" request = Net::HTTP::Put.new(event.sprintf(@uri.request_uri)) when "post" request = Net::HTTP::Post.new(event.sprintf(@uri.request_uri)) else @logger.error("Unknown verb: ", :verb => @verb) end if @headers @headers.each do |k,v| request[k] = event.sprintf(v) end end request["Content-Type"] = "application/json" request.body = event.to_json_with_metadata response = @agent.request(request) #puts response.code rescue Exception => e @logger.warn("Unhandled exception: ", :request => request, :response => response, :exception => e, :stacktrace => e.backtrace) end end # def encode end # class LogStash::Outputs::Https
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logstash-output-https-0.0.2 | lib/logstash/outputs/https.rb |