Class: LogStash::Outputs::Juggernaut
- Inherits:
-
Base
- Object
- Base
- LogStash::Outputs::Juggernaut
- Defined in:
- lib/logstash/outputs/juggernaut.rb
Overview
Push messages to the juggernaut websockets server:
Wraps Websockets and supports other methods (including xhr longpolling) This is basically, just an extension of the redis output (Juggernaut pulls messages from redis). But it pushes messages to a particular channel and formats the messages in the way juggernaut expects.
Instance Method Summary collapse
Instance Method Details
#close ⇒ Object
98 99 100 101 102 103 |
# File 'lib/logstash/outputs/juggernaut.rb', line 98 def close if @data_type == 'channel' and @redis @redis.quit @redis = nil end end |
#receive(event) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/logstash/outputs/juggernaut.rb', line 74 def receive(event) return unless output?(event) begin @redis ||= connect if @message_format formatted = event.sprintf(@message_format) else formatted = event.to_json end = { "channels" => @channels.collect{ |x| event.sprintf(x) }, "data" => event["message"] } @redis.publish 'juggernaut', LogStash::Json.dump() rescue => e @logger.warn("Failed to send event to redis", :event => event, :identity => identity, :exception => e, :backtrace => e.backtrace) raise e end end |
#register ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/logstash/outputs/juggernaut.rb', line 42 def register require 'redis' if not @channels raise RuntimeError.new( "Must define the channels on which to publish the messages" ) end # end TODO @redis = nil end |