fluent-plugin-redis 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.rdoc +33 -0
- data/Rakefile +2 -0
- data/VERSION +1 -0
- data/fluent-plugin-redis.gemspec +22 -0
- data/lib/fluent/plugin/out_redis.rb +55 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
= Redis output plugin for Fluent
|
2
|
+
|
3
|
+
== Configuratin
|
4
|
+
|
5
|
+
<match redis.**>
|
6
|
+
type redis
|
7
|
+
|
8
|
+
host localhost
|
9
|
+
port 6379
|
10
|
+
|
11
|
+
# database number and namespace params are optional.
|
12
|
+
db_number 0 # 0 is default
|
13
|
+
namespace fluent # 'fluent' is default
|
14
|
+
|
15
|
+
# Other buffer configurations here
|
16
|
+
</match>
|
17
|
+
|
18
|
+
|
19
|
+
== Contributing to fluent-plugin-redis
|
20
|
+
|
21
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
22
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
23
|
+
* Fork the project
|
24
|
+
* Start a feature/bugfix branch
|
25
|
+
* Commit and push until you are happy with your contribution
|
26
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
27
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
28
|
+
|
29
|
+
|
30
|
+
== Copyright
|
31
|
+
|
32
|
+
Copyright:: Copyright (c) 2011- Yuki Nishijima
|
33
|
+
License:: Apache License, Version 2.0
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "fluent-plugin-redis"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Yuki Nishijima"]
|
9
|
+
s.date = %q{2011-09-30}
|
10
|
+
s.email = "mail@yukinishijima.net"
|
11
|
+
s.homepage = "http://github.com/yuki24/fluent-plugin-redis"
|
12
|
+
s.summary = "Redis output plugin for Fluent"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_dependency %q<fluent>, ["~> 0.9.14"]
|
20
|
+
s.add_dependency 'redis'
|
21
|
+
s.add_dependency 'redis-namespace'
|
22
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Fluent
|
2
|
+
class RedisOutput < BufferedOutput
|
3
|
+
Fluent::Plugin.register_output('redis', self)
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
require 'redis/namespace'
|
8
|
+
require 'msgpack'
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure(conf)
|
12
|
+
super
|
13
|
+
|
14
|
+
@host = conf.has_key?('host') ? conf['host'] : 'localhost'
|
15
|
+
@port = conf.has_key?('port') ? conf['port'] : 6379
|
16
|
+
@db = conf.has_key?('db') ? conf['db'] : nil
|
17
|
+
@namespace = conf.has_key?('namespace') ? conf['namespace'] : :fluent
|
18
|
+
end
|
19
|
+
|
20
|
+
def start
|
21
|
+
super
|
22
|
+
redis = Redis.new(:host => @host, :port => @port,
|
23
|
+
:thread_safe => true, :db => @db)
|
24
|
+
@redis = Redis::Namespace.new(@namespace, :redis => redis)
|
25
|
+
end
|
26
|
+
|
27
|
+
def shutdown
|
28
|
+
@redis.quit
|
29
|
+
end
|
30
|
+
|
31
|
+
def format(tag, event)
|
32
|
+
# event.record[:identifier]=[tag,event.time].join(".")
|
33
|
+
# event.record.to_msgpack
|
34
|
+
identifier=[tag,event.time].join(".")
|
35
|
+
[ identifier, event.record ].to_msgpack
|
36
|
+
end
|
37
|
+
|
38
|
+
def write(chunk)
|
39
|
+
@redis.pipelined {
|
40
|
+
chunk.open { |io|
|
41
|
+
begin
|
42
|
+
MessagePack::Unpacker.new(io).each { |record|
|
43
|
+
# identifier = record["identifier"].to_s
|
44
|
+
# record.delete("identifier")
|
45
|
+
# @redis.mapped_hmset identifier, record
|
46
|
+
@redis.mapped_hmset record[0], record[1]
|
47
|
+
}
|
48
|
+
rescue EOFError
|
49
|
+
# EOFError always occured when reached end of chunk.
|
50
|
+
end
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-redis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yuki Nishijima
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-09-30 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: fluent
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.9.14
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: redis
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: redis-namespace
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
description:
|
49
|
+
email: mail@yukinishijima.net
|
50
|
+
executables: []
|
51
|
+
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files: []
|
55
|
+
|
56
|
+
files:
|
57
|
+
- .gitignore
|
58
|
+
- Gemfile
|
59
|
+
- README.rdoc
|
60
|
+
- Rakefile
|
61
|
+
- VERSION
|
62
|
+
- fluent-plugin-redis.gemspec
|
63
|
+
- lib/fluent/plugin/out_redis.rb
|
64
|
+
homepage: http://github.com/yuki24/fluent-plugin-redis
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
requirements: []
|
85
|
+
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.10
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Redis output plugin for Fluent
|
91
|
+
test_files: []
|
92
|
+
|