Class: LogStash::Outputs::Redis

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/redis.rb

Instance Attribute Summary

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LogStash::Outputs::Base

Instance Method Details

#receive(event) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/logstash/outputs/redis.rb', line 22

def receive(event)
  @redis.rpush(event.sprintf(@queue), {
    :source_host => @hostname, 
    :source => event.source,
    :message => event.message
  }.to_json)
end

#registerObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/logstash/outputs/redis.rb', line 7

def register
@port = nil
@password = nil
@host = @url.host
_, @db, @queue = @url.path.split('/')
require 'socket'
@hostname = Socket.gethostname
@work = []
@redis = EM::Protocols::Redis.connect({
  :host => @host, 
  :port => @port, 
  :db => @db
})
end