class LogStash::Outputs::Loggly

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.

Public Instance Methods

receive(event) click to toggle source
# File lib/logstash/outputs/loggly.rb, line 68
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() click to toggle source
# File lib/logstash/outputs/loggly.rb, line 63
def register
  # nothing to do
end