Sha256: e7d2f1670ef7b5f61de56f567904a313346709db94f4baff5a735a6e1913b5fe

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

require 'redis'
require 'redis/namespace'

class Woodchuck::Output::Redis < Woodchuck::Output
  attr_accessor :url, :host, :port, :db, :namespace
  
  def initialize
    super
    @type = :redis
    @url = Addressable::URI.parse(ENV['REDIS_URL'] || 'redis://localhost:6379/9')
    @namespace = ENV['REDIS_NAMESPACE'] || 'logstash:woodchuck'
  end
  
  def redis
    client = ::Redis.new(:url => url)
    ::Redis::Namespace.new(namespace, :redis => client)
  end
  
  def handle(event)
    redis.lpush("events", event.to_json)
    @logger.info "Logging event to Redis", event.to_hash
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
woodchuck-0.0.1 lib/woodchuck/output/redis.rb