fluent-plugin-scribe 0.10.5 → 0.10.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +13 -5
- data/README.rdoc +19 -8
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/fluent-plugin-scribe.gemspec +13 -13
- data/lib/fluent/plugin/in_scribe.rb +41 -25
- data/lib/fluent/plugin/out_scribe.rb +27 -3
- data/test/plugin/in_scribe.rb +76 -1
- data/test/plugin/out_scribe.rb +155 -0
- metadata +12 -10
data/ChangeLog
CHANGED
@@ -1,18 +1,26 @@
|
|
1
|
-
Release 0.10.
|
1
|
+
Release 0.10.6 - 2011/01/23
|
2
2
|
|
3
|
-
*
|
4
|
-
|
3
|
+
* support add_prefix / remove_prefix option
|
4
|
+
* update thrift to 0.8.0
|
5
|
+
* support remove_newline option
|
5
6
|
|
6
7
|
|
7
|
-
Release 0.10.
|
8
|
+
Release 0.10.5 - 2011/11/16
|
9
|
+
|
10
|
+
* fixed broken gemspec
|
8
11
|
|
9
12
|
|
10
|
-
Release 0.10.
|
13
|
+
Release 0.10.4 - 2011/11/14
|
11
14
|
|
12
15
|
* fixed encoding problem (work-around for thrift-rb)
|
13
16
|
- contributed by @tagomoris and @frsyuki
|
14
17
|
|
15
18
|
|
19
|
+
Release 0.10.3 - 2011/10/16
|
20
|
+
|
21
|
+
* modify summary of gemspec
|
22
|
+
|
23
|
+
|
16
24
|
Release 0.10.2 - 2011/10/16
|
17
25
|
|
18
26
|
* implement out_scribe plugin
|
data/README.rdoc
CHANGED
@@ -35,7 +35,11 @@ The category field is used as fluentd 'tag'.
|
|
35
35
|
|
36
36
|
== How to use?
|
37
37
|
|
38
|
-
|
38
|
+
fluent-plugin-scribe contains both input and output.
|
39
|
+
|
40
|
+
=== Scribe Input
|
41
|
+
|
42
|
+
Please add the following configurations to fluent.conf. This allows your Scribe client to import logs through port 1463.
|
39
43
|
|
40
44
|
# Scribe input
|
41
45
|
<source>
|
@@ -43,26 +47,33 @@ Please add the following configurations to fluent.conf.
|
|
43
47
|
port 1463
|
44
48
|
</source>
|
45
49
|
|
50
|
+
These options are supported.
|
51
|
+
|
52
|
+
* port: port number (default: 1463)
|
53
|
+
* bind: bind address (default: 0.0.0.0)
|
54
|
+
* server_type: server architecture either in 'simple', 'threaded', 'thread_pool', 'nonblocking' (default: nonblocking)
|
55
|
+
* is_framed: use framed protocol or not (default: true)
|
56
|
+
* add_prefix: prefix string, added to the tag (default: nil)
|
57
|
+
|
58
|
+
=== Scribe Output
|
59
|
+
|
60
|
+
Please add the following configurations to fluent.conf. This allows fluentd to output its logs into another Scribe server. Note that fluentd conveys semi-structured data while Scribe conveys unstructured data, thus, 'field_ref' parameter is prepared to specify which field will be transferred.
|
61
|
+
|
46
62
|
# Scribe output
|
47
63
|
<match *>
|
48
64
|
type scribe
|
49
65
|
host scribed-host.local
|
50
66
|
port 1463
|
67
|
+
field_ref message
|
51
68
|
</match>
|
52
69
|
|
53
70
|
These options are supported.
|
54
71
|
|
55
|
-
* (for input)
|
56
|
-
* port: port number (default: 1463)
|
57
|
-
* bind: bind address (default: 0.0.0.0)
|
58
|
-
* server_type: server architecture either in 'simple', 'threaded', 'thread_pool', 'nonblocking' (default: nonblocking)
|
59
|
-
* is_framed: use framed protocol or not (default: true)
|
60
|
-
|
61
|
-
* (for output)
|
62
72
|
* host: host name or address (default: localhost)
|
63
73
|
* port: port number (default: 1463)
|
64
74
|
* field_ref: field name which sent as scribe log message (default: message)
|
65
75
|
* timeout: thrift protocol timeout (default: 30)
|
76
|
+
* remove_prefix: prefix string, removed from the tag (default: nil)
|
66
77
|
|
67
78
|
== For Developers
|
68
79
|
|
data/Rakefile
CHANGED
@@ -6,14 +6,14 @@ begin
|
|
6
6
|
require 'jeweler'
|
7
7
|
Jeweler::Tasks.new do |gemspec|
|
8
8
|
gemspec.name = "fluent-plugin-scribe"
|
9
|
-
gemspec.summary = "Scribe Input/Output plugin for
|
9
|
+
gemspec.summary = "Scribe Input/Output plugin for Fluentd event collector"
|
10
10
|
gemspec.author = "Kazuki Ohta"
|
11
11
|
gemspec.email = "kazuki.ohta@gmail.com"
|
12
12
|
gemspec.homepage = "https://github.com/fluent/fluent-plugin-scribe"
|
13
13
|
gemspec.has_rdoc = false
|
14
14
|
gemspec.require_paths = ["lib"]
|
15
|
-
gemspec.add_dependency "fluentd", "~> 0.10.
|
16
|
-
gemspec.add_dependency "thrift", "~> 0.
|
15
|
+
gemspec.add_dependency "fluentd", "~> 0.10.0"
|
16
|
+
gemspec.add_dependency "thrift", "~> 0.8.0"
|
17
17
|
gemspec.test_files = Dir["test/**/*.rb"]
|
18
18
|
gemspec.files = Dir["bin/**/*", "lib/**/*", "test/**/*.rb"] +
|
19
19
|
%w[example.conf VERSION AUTHORS Rakefile fluent-plugin-scribe.gemspec]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.6
|
@@ -5,14 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fluent-plugin-scribe}
|
8
|
-
s.version = "0.10.
|
8
|
+
s.version = "0.10.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{
|
13
|
-
s.default_executable = %q{fluent-scribe-remote}
|
11
|
+
s.authors = [%q{Kazuki Ohta}]
|
12
|
+
s.date = %q{2012-01-23}
|
14
13
|
s.email = %q{kazuki.ohta@gmail.com}
|
15
|
-
s.executables = [
|
14
|
+
s.executables = [%q{fluent-scribe-remote}]
|
16
15
|
s.extra_rdoc_files = [
|
17
16
|
"ChangeLog",
|
18
17
|
"README.rdoc"
|
@@ -34,27 +33,28 @@ Gem::Specification.new do |s|
|
|
34
33
|
"lib/fluent/plugin/thrift/scribe.thrift",
|
35
34
|
"lib/fluent/plugin/thrift/scribe_constants.rb",
|
36
35
|
"lib/fluent/plugin/thrift/scribe_types.rb",
|
37
|
-
"test/plugin/in_scribe.rb"
|
36
|
+
"test/plugin/in_scribe.rb",
|
37
|
+
"test/plugin/out_scribe.rb"
|
38
38
|
]
|
39
39
|
s.homepage = %q{https://github.com/fluent/fluent-plugin-scribe}
|
40
|
-
s.require_paths = [
|
41
|
-
s.rubygems_version = %q{1.6
|
42
|
-
s.summary = %q{Scribe Input/Output plugin for
|
43
|
-
s.test_files = [
|
40
|
+
s.require_paths = [%q{lib}]
|
41
|
+
s.rubygems_version = %q{1.8.6}
|
42
|
+
s.summary = %q{Scribe Input/Output plugin for Fluentd event collector}
|
43
|
+
s.test_files = [%q{test/plugin/in_scribe.rb}, %q{test/plugin/out_scribe.rb}]
|
44
44
|
|
45
45
|
if s.respond_to? :specification_version then
|
46
46
|
s.specification_version = 3
|
47
47
|
|
48
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
49
|
s.add_runtime_dependency(%q<fluentd>, ["~> 0.10.0"])
|
50
|
-
s.add_runtime_dependency(%q<thrift>, ["~> 0.
|
50
|
+
s.add_runtime_dependency(%q<thrift>, ["~> 0.8.0"])
|
51
51
|
else
|
52
52
|
s.add_dependency(%q<fluentd>, ["~> 0.10.0"])
|
53
|
-
s.add_dependency(%q<thrift>, ["~> 0.
|
53
|
+
s.add_dependency(%q<thrift>, ["~> 0.8.0"])
|
54
54
|
end
|
55
55
|
else
|
56
56
|
s.add_dependency(%q<fluentd>, ["~> 0.10.0"])
|
57
|
-
s.add_dependency(%q<thrift>, ["~> 0.
|
57
|
+
s.add_dependency(%q<thrift>, ["~> 0.8.0"])
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -20,13 +20,13 @@ module Fluent
|
|
20
20
|
class ScribeInput < Input
|
21
21
|
Plugin.register_input('scribe', self)
|
22
22
|
|
23
|
-
include DetachMultiProcessMixin
|
24
|
-
|
25
23
|
config_param :port, :integer, :default => 1463
|
26
24
|
config_param :bind, :string, :default => '0.0.0.0'
|
27
25
|
config_param :server_type, :string, :default => 'nonblocking'
|
28
26
|
config_param :is_framed, :bool, :default => true
|
29
27
|
config_param :body_size_limit, :size, :default => 32*1024*1024 # TODO default
|
28
|
+
config_param :add_prefix, :string, :default => nil
|
29
|
+
config_param :remove_newline, :bool, :default => false
|
30
30
|
|
31
31
|
def initialize
|
32
32
|
require 'thrift'
|
@@ -48,6 +48,8 @@ class ScribeInput < Input
|
|
48
48
|
$log.debug "listening scribe on #{@bind}:#{@port}"
|
49
49
|
|
50
50
|
handler = FluentScribeHandler.new
|
51
|
+
handler.add_prefix = @add_prefix
|
52
|
+
handler.remove_newline = @remove_newline
|
51
53
|
processor = Scribe::Processor.new handler
|
52
54
|
|
53
55
|
@transport = Thrift::ServerSocket.new @bind, @port
|
@@ -82,16 +84,7 @@ class ScribeInput < Input
|
|
82
84
|
else
|
83
85
|
raise ConfigError, "in_scribe: unsupported server_type '#{@server_type}'"
|
84
86
|
end
|
85
|
-
|
86
|
-
if @detach_process
|
87
|
-
@transport.listen
|
88
|
-
def @transport.listen
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
detach_multi_process do
|
93
|
-
@thread = Thread.new(&method(:run))
|
94
|
-
end
|
87
|
+
@thread = Thread.new(&method(:run))
|
95
88
|
end
|
96
89
|
|
97
90
|
def shutdown
|
@@ -107,21 +100,44 @@ class ScribeInput < Input
|
|
107
100
|
end
|
108
101
|
|
109
102
|
class FluentScribeHandler
|
103
|
+
attr_accessor :add_prefix
|
104
|
+
attr_accessor :remove_newline
|
105
|
+
|
110
106
|
def Log(msgs)
|
111
107
|
begin
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
108
|
+
if @add_prefix
|
109
|
+
if @remove_newline
|
110
|
+
msgs.each { |msg|
|
111
|
+
record = {
|
112
|
+
'message' => msg.message.force_encoding('UTF-8').chomp
|
113
|
+
}
|
114
|
+
Engine.emit(@add_prefix + '.' + msg.category, Engine.now, record)
|
115
|
+
}
|
116
|
+
else
|
117
|
+
msgs.each { |msg|
|
118
|
+
record = {
|
119
|
+
'message' => msg.message.force_encoding('UTF-8')
|
120
|
+
}
|
121
|
+
Engine.emit(@add_prefix + '.' + msg.category, Engine.now, record)
|
122
|
+
}
|
123
|
+
end
|
124
|
+
else
|
125
|
+
if @remove_newline
|
126
|
+
msgs.each { |msg|
|
127
|
+
record = {
|
128
|
+
'message' => msg.message.force_encoding('UTF-8').chomp
|
129
|
+
}
|
130
|
+
Engine.emit(msg.category, Engine.now, record)
|
131
|
+
}
|
132
|
+
else
|
133
|
+
msgs.each { |msg|
|
134
|
+
record = {
|
135
|
+
'message' => msg.message.force_encoding('UTF-8')
|
136
|
+
}
|
137
|
+
Engine.emit(msg.category, Engine.now, record)
|
138
|
+
}
|
139
|
+
end
|
140
|
+
end
|
125
141
|
return ResultCode::OK
|
126
142
|
rescue => e
|
127
143
|
$log.error "unexpected error", :error=>$!.to_s
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#
|
18
18
|
module Fluent
|
19
19
|
|
20
|
-
class ScribeOutput <
|
20
|
+
class ScribeOutput < BufferedOutput
|
21
21
|
Fluent::Plugin.register_output('scribe', self)
|
22
22
|
|
23
23
|
config_param :host, :string, :default => 'localhost'
|
@@ -25,6 +25,9 @@ class ScribeOutput < ObjectBufferedOutput
|
|
25
25
|
config_param :field_ref, :string, :default => 'message'
|
26
26
|
config_param :timeout, :integer, :default => 30
|
27
27
|
|
28
|
+
config_param :remove_prefix, :string, :default => nil
|
29
|
+
config_param :default_category, :string, :default => 'unknown'
|
30
|
+
|
28
31
|
def initialize
|
29
32
|
require 'thrift'
|
30
33
|
$:.unshift File.join(File.dirname(__FILE__), 'thrift')
|
@@ -43,13 +46,33 @@ class ScribeOutput < ObjectBufferedOutput
|
|
43
46
|
|
44
47
|
def start
|
45
48
|
super
|
49
|
+
|
50
|
+
if @remove_prefix
|
51
|
+
@removed_prefix_string = @remove_prefix + '.'
|
52
|
+
@removed_length = @removed_prefix_string.length
|
53
|
+
end
|
46
54
|
end
|
47
55
|
|
48
56
|
def shutdown
|
49
57
|
super
|
50
58
|
end
|
51
59
|
|
52
|
-
def
|
60
|
+
def format(tag, time, record)
|
61
|
+
if @remove_prefix and
|
62
|
+
( (tag[0, @removed_length] == @removed_prefix_string and tag.length > @removed_length) or
|
63
|
+
tag == @remove_prefix)
|
64
|
+
[(tag[@removed_length..-1] || @default_category), record].to_msgpack
|
65
|
+
else
|
66
|
+
[tag, record].to_msgpack
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def write(chunk)
|
71
|
+
records = []
|
72
|
+
chunk.msgpack_each { |arr|
|
73
|
+
records << arr
|
74
|
+
}
|
75
|
+
|
53
76
|
socket = Thrift::Socket.new @host, @port, @timeout
|
54
77
|
transport = Thrift::FramedTransport.new socket
|
55
78
|
protocol = Thrift::BinaryProtocol.new transport, false, false
|
@@ -58,7 +81,8 @@ class ScribeOutput < ObjectBufferedOutput
|
|
58
81
|
transport.open
|
59
82
|
begin
|
60
83
|
entries = []
|
61
|
-
|
84
|
+
records.each { |r|
|
85
|
+
tag, record = r
|
62
86
|
next unless record.has_key?(@field_ref)
|
63
87
|
entry = LogEntry.new
|
64
88
|
entry.category = tag
|
data/test/plugin/in_scribe.rb
CHANGED
@@ -20,6 +20,7 @@ class ScribeInputTest < Test::Unit::TestCase
|
|
20
20
|
d = create_driver
|
21
21
|
assert_equal 14630, d.instance.port
|
22
22
|
assert_equal '127.0.0.1', d.instance.bind
|
23
|
+
assert_equal false, d.instance.remove_newline
|
23
24
|
end
|
24
25
|
|
25
26
|
def test_time
|
@@ -31,8 +32,82 @@ class ScribeInputTest < Test::Unit::TestCase
|
|
31
32
|
d.expect_emit "tag1", time, {"message"=>'aiueo'}
|
32
33
|
d.expect_emit "tag2", time, {"message"=>'aiueo'}
|
33
34
|
|
35
|
+
emits = [
|
36
|
+
['tag1', time, {"message"=>'aiueo'}],
|
37
|
+
['tag2', time, {"message"=>'aiueo'}],
|
38
|
+
]
|
34
39
|
d.run do
|
35
|
-
|
40
|
+
emits.each { |tag, time, record|
|
41
|
+
res = send(tag, record['message'])
|
42
|
+
assert_equal ResultCode::OK, res
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_add_prefix
|
48
|
+
d = create_driver(CONFIG + %[
|
49
|
+
add_prefix scribe
|
50
|
+
])
|
51
|
+
|
52
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
53
|
+
Fluent::Engine.now = time
|
54
|
+
|
55
|
+
d.expect_emit "scribe.tag1", time, {"message"=>'aiueo'}
|
56
|
+
d.expect_emit "scribe.tag2", time, {"message"=>'aiueo'}
|
57
|
+
|
58
|
+
emits = [
|
59
|
+
['tag1', time, {"message"=>'aiueo'}],
|
60
|
+
['tag2', time, {"message"=>'aiueo'}],
|
61
|
+
]
|
62
|
+
d.run do
|
63
|
+
emits.each { |tag, time, record|
|
64
|
+
res = send(tag, record['message'])
|
65
|
+
assert_equal ResultCode::OK, res
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
d2 = create_driver(CONFIG + %[
|
70
|
+
add_prefix scribe.input
|
71
|
+
])
|
72
|
+
|
73
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
74
|
+
Fluent::Engine.now = time
|
75
|
+
|
76
|
+
d2.expect_emit "scribe.input.tag3", time, {"message"=>'aiueo'}
|
77
|
+
d2.expect_emit "scribe.input.tag4", time, {"message"=>'aiueo'}
|
78
|
+
|
79
|
+
emits = [
|
80
|
+
['tag3', time, {"message"=>'aiueo'}],
|
81
|
+
['tag4', time, {"message"=>'aiueo'}],
|
82
|
+
]
|
83
|
+
d2.run do
|
84
|
+
emits.each { |tag, time, record|
|
85
|
+
res = send(tag, record['message'])
|
86
|
+
assert_equal ResultCode::OK, res
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_remove_newline
|
92
|
+
d = create_driver(CONFIG + %[
|
93
|
+
remove_newline true
|
94
|
+
])
|
95
|
+
assert_equal true, d.instance.remove_newline
|
96
|
+
|
97
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
98
|
+
Fluent::Engine.now = time
|
99
|
+
|
100
|
+
d.expect_emit "tag1", time, {"message"=>'aiueo'}
|
101
|
+
d.expect_emit "tag2", time, {"message"=>'kakikukeko'}
|
102
|
+
d.expect_emit "tag3", time, {"message"=>'sasisuseso'}
|
103
|
+
|
104
|
+
emits = [
|
105
|
+
['tag1', time, {"message"=>"aiueo\n"}],
|
106
|
+
['tag2', time, {"message"=>"kakikukeko\n"}],
|
107
|
+
['tag3', time, {"message"=>"sasisuseso"}],
|
108
|
+
]
|
109
|
+
d.run do
|
110
|
+
emits.each { |tag, time, record|
|
36
111
|
res = send(tag, record['message'])
|
37
112
|
assert_equal ResultCode::OK, res
|
38
113
|
}
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'lib/fluent/plugin/out_scribe'
|
4
|
+
|
5
|
+
class ScribeOutputTest < Test::Unit::TestCase
|
6
|
+
CONFIG = %[
|
7
|
+
host 127.0.0.1
|
8
|
+
port 14630
|
9
|
+
]
|
10
|
+
|
11
|
+
def create_driver(conf=CONFIG, tag='test')
|
12
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::ScribeOutput, tag).configure(conf)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_configure
|
16
|
+
d = create_driver('')
|
17
|
+
|
18
|
+
assert_equal 'localhost', d.instance.host
|
19
|
+
assert_equal 1463, d.instance.port
|
20
|
+
assert_equal 'message', d.instance.field_ref
|
21
|
+
assert_equal 30, d.instance.timeout
|
22
|
+
assert_equal 'unknown', d.instance.default_category
|
23
|
+
assert_nil d.instance.remove_prefix
|
24
|
+
|
25
|
+
d = create_driver
|
26
|
+
|
27
|
+
assert_equal '127.0.0.1', d.instance.host
|
28
|
+
assert_equal 14630, d.instance.port
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_format
|
32
|
+
time = Time.parse("2011-12-21 13:14:15 UTC").to_i
|
33
|
+
|
34
|
+
d = create_driver
|
35
|
+
d.emit({"message" => "testing first", "message2" => "testing first another data"}, time)
|
36
|
+
d.emit({"message" => "testing second", "message2" => "testing second another data"}, time)
|
37
|
+
d.emit({"message" => "testing third", "message2" => "testing third another data"}, time)
|
38
|
+
d.expect_format [d.tag, {"message" => "testing first", "message2" => "testing first another data"}].to_msgpack
|
39
|
+
d.expect_format [d.tag, {"message" => "testing second", "message2" => "testing second another data"}].to_msgpack
|
40
|
+
d.expect_format [d.tag, {"message" => "testing third", "message2" => "testing third another data"}].to_msgpack
|
41
|
+
d.run
|
42
|
+
|
43
|
+
d = create_driver(CONFIG + %[
|
44
|
+
field_ref message2
|
45
|
+
remove_prefix test
|
46
|
+
], 'test.scribeplugin')
|
47
|
+
assert_equal 'test.scribeplugin', d.tag
|
48
|
+
|
49
|
+
d.emit({"message" => "xxx testing first", "message2" => "xxx testing first another data"}, time)
|
50
|
+
d.emit({"message" => "xxx testing second", "message2" => "xxx testing second another data"}, time)
|
51
|
+
d.expect_format ['scribeplugin', {"message" => "xxx testing first", "message2" => "xxx testing first another data"}].to_msgpack
|
52
|
+
d.expect_format ['scribeplugin', {"message" => "xxx testing second", "message2" => "xxx testing second another data"}].to_msgpack
|
53
|
+
d.run
|
54
|
+
|
55
|
+
d = create_driver(CONFIG + %[
|
56
|
+
field_ref message2
|
57
|
+
remove_prefix test
|
58
|
+
], 'xxx.test.scribeplugin')
|
59
|
+
assert_equal 'xxx.test.scribeplugin', d.tag
|
60
|
+
d.emit({"message" => "xxx testing first", "message2" => "xxx testing first another data"}, time)
|
61
|
+
d.expect_format ['xxx.test.scribeplugin', {"message" => "xxx testing first", "message2" => "xxx testing first another data"}].to_msgpack
|
62
|
+
d.run
|
63
|
+
|
64
|
+
d = create_driver(CONFIG + %[
|
65
|
+
field_ref message2
|
66
|
+
remove_prefix test
|
67
|
+
], 'test')
|
68
|
+
assert_equal 'test', d.tag
|
69
|
+
d.emit({"message" => "xxx testing first", "message2" => "xxx testing first another data"}, time)
|
70
|
+
d.expect_format ['unknown', {"message" => "xxx testing first", "message2" => "xxx testing first another data"}].to_msgpack
|
71
|
+
d.run
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_write
|
75
|
+
time = Time.parse("2011-12-21 13:14:15 UTC").to_i
|
76
|
+
|
77
|
+
d = create_driver
|
78
|
+
d.emit({"message" => "testing first", "message2" => "testing first another data"}, time)
|
79
|
+
d.emit({"message" => "testing second", "message2" => "testing second another data"}, time)
|
80
|
+
d.emit({"message" => "testing third", "message2" => "testing third another data"}, time)
|
81
|
+
result = d.run
|
82
|
+
assert_equal ResultCode::OK, result
|
83
|
+
assert_equal [[d.tag, 'testing first'], [d.tag, 'testing second'], [d.tag,'testing third']], $handler.last
|
84
|
+
|
85
|
+
d = create_driver(CONFIG + %[
|
86
|
+
field_ref message2
|
87
|
+
remove_prefix test
|
88
|
+
], 'test.scribeplugin')
|
89
|
+
assert_equal 'test.scribeplugin', d.tag
|
90
|
+
d.emit({"message" => "xxx testing first", "message2" => "xxx testing first another data"}, time)
|
91
|
+
d.emit({"message" => "xxx testing second", "message2" => "xxx testing second another data"}, time)
|
92
|
+
result = d.run
|
93
|
+
assert_equal ResultCode::OK, result
|
94
|
+
assert_equal [['scribeplugin', 'xxx testing first another data'], ['scribeplugin', 'xxx testing second another data']], $handler.last
|
95
|
+
|
96
|
+
d = create_driver(CONFIG + %[
|
97
|
+
field_ref message2
|
98
|
+
remove_prefix test
|
99
|
+
], 'xxx.test.scribeplugin')
|
100
|
+
assert_equal 'xxx.test.scribeplugin', d.tag
|
101
|
+
d.emit({"message" => "yyy testing first", "message2" => "yyy testing first another data"}, time)
|
102
|
+
result = d.run
|
103
|
+
assert_equal ResultCode::OK, result
|
104
|
+
assert_equal [['xxx.test.scribeplugin', 'yyy testing first another data']], $handler.last
|
105
|
+
|
106
|
+
d = create_driver(CONFIG + %[
|
107
|
+
field_ref message2
|
108
|
+
remove_prefix test
|
109
|
+
], 'test')
|
110
|
+
assert_equal 'test', d.tag
|
111
|
+
d.emit({"message" => "zzz testing first", "message2" => "zzz testing first another data"}, time)
|
112
|
+
result = d.run
|
113
|
+
assert_equal ResultCode::OK, result
|
114
|
+
assert_equal [[d.instance.default_category, 'zzz testing first another data']], $handler.last
|
115
|
+
end
|
116
|
+
|
117
|
+
def setup
|
118
|
+
Fluent::Test.setup
|
119
|
+
$handler = TestScribeServerHandler.new
|
120
|
+
@dummy_server_thread = Thread.new do
|
121
|
+
begin
|
122
|
+
transport = Thrift::ServerSocket.new '127.0.0.1', 14630
|
123
|
+
processor = Scribe::Processor.new $handler
|
124
|
+
transport_factory = Thrift::FramedTransportFactory.new
|
125
|
+
protocol_factory = Thrift::BinaryProtocolFactory.new
|
126
|
+
protocol_factory.instance_eval {|obj|
|
127
|
+
def get_protocol(trans) # override
|
128
|
+
Thrift::BinaryProtocol.new(trans, strict_read=false, strict_write=false)
|
129
|
+
end
|
130
|
+
}
|
131
|
+
server = Thrift::SimpleServer.new processor, transport, transport_factory, protocol_factory
|
132
|
+
server.serve
|
133
|
+
ensure
|
134
|
+
transport.close unless transport.closed?
|
135
|
+
end
|
136
|
+
end
|
137
|
+
sleep 0.1 # boo...
|
138
|
+
end
|
139
|
+
|
140
|
+
def teardown
|
141
|
+
@dummy_server_thread.kill
|
142
|
+
@dummy_server_thread.join
|
143
|
+
end
|
144
|
+
|
145
|
+
class TestScribeServerHandler
|
146
|
+
attr :last
|
147
|
+
def initialize
|
148
|
+
@last = []
|
149
|
+
end
|
150
|
+
def Log(msgs)
|
151
|
+
@last = msgs.map{|msg| [msg.category, msg.message.force_encoding('UTF-8')]}
|
152
|
+
ResultCode::OK
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-scribe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
16
|
-
requirement: &
|
16
|
+
requirement: &2160486020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.10.
|
21
|
+
version: 0.10.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2160486020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thrift
|
27
|
-
requirement: &
|
27
|
+
requirement: &2160485540 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.8.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2160485540
|
36
36
|
description:
|
37
37
|
email: kazuki.ohta@gmail.com
|
38
38
|
executables:
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/fluent/plugin/thrift/scribe_constants.rb
|
60
60
|
- lib/fluent/plugin/thrift/scribe_types.rb
|
61
61
|
- test/plugin/in_scribe.rb
|
62
|
+
- test/plugin/out_scribe.rb
|
62
63
|
- ChangeLog
|
63
64
|
- README.rdoc
|
64
65
|
homepage: https://github.com/fluent/fluent-plugin-scribe
|
@@ -81,9 +82,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
82
|
version: '0'
|
82
83
|
requirements: []
|
83
84
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.8.
|
85
|
+
rubygems_version: 1.8.6
|
85
86
|
signing_key:
|
86
87
|
specification_version: 3
|
87
|
-
summary: Scribe Input/Output plugin for
|
88
|
+
summary: Scribe Input/Output plugin for Fluentd event collector
|
88
89
|
test_files:
|
89
90
|
- test/plugin/in_scribe.rb
|
91
|
+
- test/plugin/out_scribe.rb
|