Class: LogStash::Outputs::Loggly
- Inherits:
-
Base
- Object
- Base
- LogStash::Outputs::Loggly
- Defined in:
- lib/logstash/outputs/loggly.rb
Overview
Got a loggly account? Use logstash to ship logs to Loggly!
This is most useful so you can use logstash to parse and structure your logs and ship structured, json events to your account at Loggly.
To use this, you’ll need to use a Loggly input with type ‘http’ and ‘json logging’ enabled.
Instance Method Summary collapse
Instance Method Details
#receive(event) ⇒ 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 |
# File 'lib/logstash/outputs/loggly.rb', line 69 def receive(event) return unless output?(event) if event == LogStash::SHUTDOWN finished return end # Send the event over http. url = URI.parse("#{@proto}://#{@host}/inputs/#{event.sprintf(@key)}") @logger.info("Loggly URL", :url => url) 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 = event.to_json response = http.request(request) if response.is_a?(Net::HTTPSuccess) @logger.info("Event send to Loggly OK!") else @logger.warn("HTTP error", :error => response.error!) end end |
#register ⇒ Object
64 65 66 |
# File 'lib/logstash/outputs/loggly.rb', line 64 def register # nothing to do end |