class LogStash::Outputs::Juggernaut
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.
Public Instance Methods
receive(event)
click to toggle source
# 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 juggernaut_message = { "channels" => @channels.collect{ |x| event.sprintf(x) }, "data" => event["message"] } @redis.publish 'juggernaut', juggernaut_message.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()
click to toggle source
# 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()
click to toggle source
# File lib/logstash/outputs/juggernaut.rb, line 98 def teardown if @data_type == 'channel' and @redis @redis.quit @redis = nil end end
Private Instance Methods
connect()
click to toggle source
# File lib/logstash/outputs/juggernaut.rb, line 56 def connect Redis.new( :host => @host, :port => @port, :timeout => @timeout, :db => @db, :password => @password ) end
identity()
click to toggle source
A string used to identify a redis instance in log messages
# File lib/logstash/outputs/juggernaut.rb, line 68 def identity @name || "redis://#{@password}@#{@host}:#{@port}/#{@db} #{@data_type}:#{@key}" end