Class: LogStash::Outputs::Loggly

Inherits:
Base
  • Object
show all
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.

Constant Summary collapse

HTTP_SUCCESS =

HTTP constants

"200"
HTTP_FORBIDDEN =
"403"
HTTP_NOT_FOUND =
"404"
HTTP_INTERNAL_SERVER_ERROR =
"500"
HTTP_GATEWAY_TIMEOUT =
"504"

Instance Method Summary collapse

Instance Method Details

#format_message(event) ⇒ Object



111
112
113
# File 'lib/logstash/outputs/loggly.rb', line 111

def format_message(event)
  event.to_json
end

#receive(event) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/logstash/outputs/loggly.rb', line 98

def receive(event)
  key = event.sprintf(@key)
  tag = event.sprintf(@tag)

  # For those cases where %{somefield} doesn't exist
  # we should ship logs with the default tag value.
  tag = 'logstash' if /^%{\w+}/.match(tag)

  # Send event
  send_event("#{@proto}://#{@host}/inputs/#{key}/tag/#{tag}", format_message(event))
end

#registerObject



93
94
95
# File 'lib/logstash/outputs/loggly.rb', line 93

def register
  # nothing to do
end