Class: LogStash::Inputs::Redis
- Inherits:
-
Threadable
- Object
- Plugin
- Base
- Threadable
- LogStash::Inputs::Redis
- Defined in:
- lib/logstash/inputs/redis.rb
Overview
Read events from a redis. Supports both redis channels and also redis lists (using BLPOP)
For more information about redis, see <redis.io/>
## ‘batch_count` note
If you use the ‘batch_count’ setting, you must use a redis version 2.6.0 or newer. Anything older does not support the operations used by batching.
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Threadable
Methods inherited from Base
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::Inputs::Threadable
Instance Method Details
#register ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/logstash/inputs/redis.rb', line 58 def register require 'redis' @redis = nil @redis_url = "redis://#{@password}@#{@host}:#{@port}/#{@db}" # TODO remove after setting key and data_type to true if @queue if @key or @data_type raise RuntimeError.new( "Cannot specify queue parameter and key or data_type" ) end @key = @queue @data_type = 'list' end if not @key or not @data_type raise RuntimeError.new( "Must define queue, or key and data_type parameters" ) end # end TODO @logger.info("Registering redis", :identity => identity) end |
#run(output_queue) ⇒ Object
240 241 242 243 244 245 246 247 248 |
# File 'lib/logstash/inputs/redis.rb', line 240 def run(output_queue) if @data_type == 'list' listener_loop :list_listener, output_queue elsif @data_type == 'channel' listener_loop :channel_listener, output_queue else listener_loop :pattern_channel_listener, output_queue end end |
#teardown ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/logstash/inputs/redis.rb', line 251 def teardown if @data_type == 'channel' and @redis @redis.unsubscribe @redis.quit @redis = nil end if @data_type == 'pattern_channel' and @redis @redis.punsubscribe @redis.quit @redis = nil end end |