Class: LogStash::Inputs::Redis
- Inherits:
-
Threadable
- Object
- Threadable
- LogStash::Inputs::Redis
- Defined in:
- lib/logstash/inputs/redis.rb
Overview
This input will read events from a Redis instance; it supports both Redis channels and lists. The list command (BLPOP) used by Logstash is supported in Redis v1.3.1+, and the channel commands used by Logstash are found in Redis v1.3.8+. While you may be able to make these Redis versions work, the best performance and stability will be found in more recent stable versions. Versions 2.6.0+ are recommended.
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.
Instance Method Summary collapse
Instance Method Details
#register ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/logstash/inputs/redis.rb', line 60 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
239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/logstash/inputs/redis.rb', line 239 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 rescue LogStash::ShutdownSignal # ignore and quit end |
#teardown ⇒ Object
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/logstash/inputs/redis.rb', line 252 def teardown @shutdown_requested = true if @redis if @data_type == 'list' @redis.quit rescue nil elsif @data_type == 'channel' @redis.unsubscribe rescue nil @redis.connection.disconnect elsif @data_type == 'pattern_channel' @redis.punsubscribe rescue nil @redis.connection.disconnect end @redis = nil end end |