Class: LogStash::Outputs::ThetaPoint
- Inherits:
-
Base
- Object
- Base
- LogStash::Outputs::ThetaPoint
- Defined in:
- lib/logstash/outputs/thetapoint.rb
Overview
This is most useful so you can use logstash to parse and structure your logs and ship structured, json events to ThetaPoint.
Instance Method Summary collapse
-
#multi_receive(events) ⇒ Object
def receive.
- #receive(event) ⇒ Object
- #register ⇒ Object
- #send_data(data) ⇒ Object
Instance Method Details
#multi_receive(events) ⇒ Object
def receive
62 63 64 65 66 |
# File 'lib/logstash/outputs/thetapoint.rb', line 62 def multi_receive(events) @logger.debug("multi_receive(#{events.length})") send_data(events.to_json) end |
#receive(event) ⇒ Object
56 57 58 59 60 |
# File 'lib/logstash/outputs/thetapoint.rb', line 56 def receive(event) @logger.debug("receive(#{event})") send_data(event.to_json) end |
#register ⇒ Object
51 52 53 |
# File 'lib/logstash/outputs/thetapoint.rb', line 51 def register @logger.debug "Initializing ThetaPoint Output", @config end |
#send_data(data) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/logstash/outputs/thetapoint.rb', line 69 def send_data(data) @logger.debug("send_data(#{data.length})") uri = "#{@proto}://#{@host}" post_data = data # Comress data if @compress post_data = Zlib::Deflate.deflate(data, Zlib::BEST_COMPRESSION) uri << "/zbulk/#{@key}" else uri << "/#{@key}" end @logger.debug("URI: #{uri}") url = URI.parse(uri) http = Net::HTTP::Proxy(@proxy_host, @proxy_port, @proxy_user, @proxy_password.value).new(url.host, url.port) if url.scheme == 'https' http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end request = Net::HTTP::Post.new(url.path) request.body = post_data begin response = http.request(request) @logger.debug "Response: #{response}" if response.is_a?(Net::HTTPSuccess) @logger.debug("Event send to ThetaPoint OK!") else @logger.warn("HTTP error", :error => response.error!) end rescue StandardError => e @logger.error("An unexpected error occurred", :exception => e.class.name, :error => e.to_s, :backtrace => e.backtrace) end # rescue end |