Class: 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.
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Outputs::Base
Instance Method Details
#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', .to_json 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 |
#teardown ⇒ Object
98 99 100 101 102 103 |
# File 'lib/logstash/outputs/juggernaut.rb', line 98 def teardown if @data_type == 'channel' and @redis @redis.quit @redis = nil end end |