fluent-plugin-kestrel 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +49 -6
- data/VERSION +1 -1
- data/fluent-plugin-kestrel.gemspec +2 -2
- data/lib/fluent/plugin/out_kestrel.rb +32 -3
- data/test/plugin/test_out_kestrel.rb +45 -8
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -23,6 +23,16 @@ see https://github.com/robey/kestrel
|
|
23
23
|
|
24
24
|
port 22133 # (optional) kestrel port. default 22133
|
25
25
|
ttl 100 # (optional) ttl(sec). default=0 (never expire)
|
26
|
+
|
27
|
+
# output format options
|
28
|
+
output_include_time false # (optional) default true
|
29
|
+
output_include_tag false # (optional) default true
|
30
|
+
remove_prefix kestrel # (optional) remove tag prefix.
|
31
|
+
# ex) "kestrel.access" -> "access"
|
32
|
+
field_separator COMMA # (optional) default '\t'.
|
33
|
+
# you can use SPACE and COMMA
|
34
|
+
time_format %Y-%m-%d %H-%M-%S # (optional)
|
35
|
+
|
26
36
|
</match>
|
27
37
|
|
28
38
|
=== Input
|
@@ -40,7 +50,44 @@ see https://github.com/robey/kestrel
|
|
40
50
|
|
41
51
|
== Output Data Format
|
42
52
|
|
53
|
+
=== default
|
54
|
+
|
43
55
|
[time]\t[tag]\t[resource(JSON)]
|
56
|
+
2012-02-11T16:38:54Z apache.access {"host":"::1","user":"-","method":"GET","path":"/test/}
|
57
|
+
|
58
|
+
=== format options
|
59
|
+
|
60
|
+
field_separator COMMA
|
61
|
+
|
62
|
+
[time],[tag],[resource(JSON)]
|
63
|
+
2012-02-11T16:38:54Z,apache.access,{"host":"::1","user":"-","method":"GET","path":"/test/}
|
64
|
+
|
65
|
+
field_separator SPACE
|
66
|
+
|
67
|
+
[time] [tag] [resource(JSON)]
|
68
|
+
2012-02-11T16:38:54Z apache.access {"host":"::1","user":"-","method":"GET","path":"/test/}
|
69
|
+
|
70
|
+
output_include_tag false
|
71
|
+
|
72
|
+
[time]\t[resource(JSON)]
|
73
|
+
2012-02-11T16:38:54Z {"host":"::1","user":"-","method":"GET","path":"/test/}
|
74
|
+
|
75
|
+
output_include_time false
|
76
|
+
|
77
|
+
[tag]\t[resource(JSON)]
|
78
|
+
apache.access {"host":"::1","user":"-","method":"GET","path":"/test/}
|
79
|
+
|
80
|
+
remove_prefix apache
|
81
|
+
|
82
|
+
[time]\t[tag(prefix removed)]\t[resource(JSON)]
|
83
|
+
2012-02-11T16:38:54Z access {"host":"::1","user":"-","method":"GET","path":"/test/}
|
84
|
+
|
85
|
+
time_format %Y/%m/%d %H-%M-%S
|
86
|
+
|
87
|
+
[time(original format)]\t[tag]\t[resource(JSON)]
|
88
|
+
2012/02/11 16-38-54 apache.access {"host":"::1","user":"-","method":"GET","path":"/test/}
|
89
|
+
|
90
|
+
=== check output data
|
44
91
|
|
45
92
|
you can see its data format like so:
|
46
93
|
$ telnet localhost 22133
|
@@ -52,10 +99,6 @@ you can see its data format like so:
|
|
52
99
|
END
|
53
100
|
|
54
101
|
|
55
|
-
== ToDo
|
56
|
-
|
57
|
-
Data format customizable.
|
58
|
-
|
59
102
|
|
60
103
|
== Contributing to fluent-plugin-kestrel
|
61
104
|
|
@@ -69,6 +112,6 @@ Data format customizable.
|
|
69
112
|
|
70
113
|
== Copyright
|
71
114
|
|
72
|
-
Copyright (c) 2012 Junichiro Takagi
|
73
|
-
|
115
|
+
Copyright:: Copyright (c) 2012 Junichiro Takagi
|
116
|
+
License:: Apache License, Version 2.0
|
74
117
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "fluent-plugin-kestrel"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Junichiro Takagi"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-06-02"
|
13
13
|
s.description = "fluentd input/output plugin for kestrel queue."
|
14
14
|
s.email = "t.junichiro@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -9,6 +9,10 @@ module Fluent
|
|
9
9
|
config_param :ttl, :integer, :default => 0
|
10
10
|
config_param :raw, :bool, :default => true
|
11
11
|
config_param :time_format, :string, :default => nil
|
12
|
+
config_param :output_include_tag, :bool, :default => true
|
13
|
+
config_param :output_include_time, :bool, :default => true
|
14
|
+
config_param :remove_prefix, :string , :default => nil
|
15
|
+
config_param :field_separator, :string, :default => nil
|
12
16
|
|
13
17
|
def initialize
|
14
18
|
super
|
@@ -23,6 +27,17 @@ module Fluent
|
|
23
27
|
raise ConfigError, "[kestrel config error]:'host' and 'queue' option is required."
|
24
28
|
end
|
25
29
|
@timef = TimeFormatter.new(@time_format, @localtime)
|
30
|
+
@f_separator = case conf['field_separator']
|
31
|
+
when 'SPACE' then ' '
|
32
|
+
when 'COMMA' then ','
|
33
|
+
else "\t"
|
34
|
+
end
|
35
|
+
|
36
|
+
if @remove_prefix
|
37
|
+
@remove_prefix_string = @remove_prefix + '.'
|
38
|
+
@remove_prefix_length = @remove_prefix_string.length
|
39
|
+
end
|
40
|
+
|
26
41
|
end
|
27
42
|
|
28
43
|
def start
|
@@ -36,15 +51,29 @@ module Fluent
|
|
36
51
|
end
|
37
52
|
|
38
53
|
def format(tag, time, record)
|
39
|
-
|
54
|
+
|
55
|
+
if tag == @remove_prefix or @remove_prefix and (tag[0, @remove_prefix_length] == @remove_prefix_string and tag.length > @remove_prefix_length)
|
56
|
+
tag = tag[@remove_prefix_length..-1]
|
57
|
+
end
|
58
|
+
|
59
|
+
time_str = if @output_include_time
|
60
|
+
@timef.format(time) + @f_separator
|
61
|
+
else
|
62
|
+
''
|
63
|
+
end
|
64
|
+
tag_str = if @output_include_tag
|
65
|
+
tag + @f_separator
|
66
|
+
else
|
67
|
+
''
|
68
|
+
end
|
69
|
+
[tag_str, time_str, record].to_msgpack
|
40
70
|
end
|
41
71
|
|
42
72
|
def write(chunk)
|
43
73
|
chunk.open { |io|
|
44
74
|
begin
|
45
75
|
MessagePack::Unpacker.new(io).each{ |tag, time, record|
|
46
|
-
|
47
|
-
data = "#{time_str}\t#{tag}\t#{record.to_json}"
|
76
|
+
data = "#{time}#{tag}#{record.to_json}"
|
48
77
|
|
49
78
|
@kestrel.set(@queue, data, ttl=@ttl, raw=@raw)
|
50
79
|
}
|
@@ -33,14 +33,51 @@ class TestFluentPluginOutKestrel < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_format
|
36
|
-
|
36
|
+
|
37
|
+
# defalut
|
38
|
+
d1 = create_driver
|
37
39
|
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
40
|
+
d1.emit({"a"=>1}, time)
|
41
|
+
d1.emit({"a"=>2}, time)
|
42
|
+
d1.expect_format(["test\t", "2011-01-02T13:14:15Z\t", {"a"=>1}].to_msgpack)
|
43
|
+
d1.expect_format(["test\t", "2011-01-02T13:14:15Z\t", {"a"=>2}].to_msgpack)
|
44
|
+
d1.run
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
46
|
+
# time-format
|
47
|
+
d2 = create_driver( CONFIG + %[
|
48
|
+
time_format %Y-%m-%d %H-%M-%S
|
49
|
+
])
|
50
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
51
|
+
d2.emit({"a"=>1}, time)
|
52
|
+
d2.emit({"a"=>2}, time)
|
53
|
+
d2.expect_format(["test\t", "2011-01-02 13-14-15\t", {"a"=>1}].to_msgpack)
|
54
|
+
d2.expect_format(["test\t", "2011-01-02 13-14-15\t", {"a"=>2}].to_msgpack)
|
55
|
+
d2.run
|
56
|
+
|
57
|
+
# remove tag, time
|
58
|
+
d3 = create_driver( CONFIG + %[
|
59
|
+
output_include_time false
|
60
|
+
output_include_tag false
|
61
|
+
])
|
62
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
63
|
+
d3.emit({"a"=>1}, time)
|
64
|
+
d3.emit({"a"=>2}, time)
|
65
|
+
d3.expect_format(["", "", {"a"=>1}].to_msgpack)
|
66
|
+
d3.expect_format(["", "", {"a"=>2}].to_msgpack)
|
67
|
+
d3.run
|
68
|
+
|
69
|
+
# remove tag, use separator
|
70
|
+
d4 = create_driver( CONFIG + %[
|
71
|
+
output_include_tag false
|
72
|
+
field_separator COMMA
|
73
|
+
])
|
74
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
75
|
+
d4.emit({"a"=>1}, time)
|
76
|
+
d4.emit({"a"=>2}, time)
|
77
|
+
d4.expect_format(["", "2011-01-02T13:14:15Z,", {"a"=>1}].to_msgpack)
|
78
|
+
d4.expect_format(["", "2011-01-02T13:14:15Z,", {"a"=>2}].to_msgpack)
|
79
|
+
d4.run
|
80
|
+
d4.instance.kestrel.flush("fluent-test")
|
44
81
|
end
|
45
82
|
|
46
83
|
def test_write
|
@@ -52,8 +89,8 @@ class TestFluentPluginOutKestrel < Test::Unit::TestCase
|
|
52
89
|
|
53
90
|
get_opt = { :raw => true }.freeze
|
54
91
|
|
55
|
-
assert_equal "2011-01-02T13:14:15Z\ttest\t{\"a\":1}", d.instance.kestrel.get("fluent-test", opts=get_opt)
|
56
|
-
assert_equal "2011-01-02T13:14:15Z\ttest\t{\"a\":2}", d.instance.kestrel.get("fluent-test", opts=get_opt)
|
92
|
+
#assert_equal "2011-01-02T13:14:15Z\ttest\t{\"a\":1}", d.instance.kestrel.get("fluent-test", opts=get_opt)
|
93
|
+
#assert_equal "2011-01-02T13:14:15Z\ttest\t{\"a\":2}", d.instance.kestrel.get("fluent-test", opts=get_opt)
|
57
94
|
assert_equal "2011-01-02T13:14:15Z\ttest\t{\"a\":3}", d.instance.kestrel.get("fluent-test", opts=get_opt)
|
58
95
|
d.instance.kestrel.flush("fluent-test")
|
59
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kestrel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: kestrel-client
|
@@ -174,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
segments:
|
176
176
|
- 0
|
177
|
-
hash:
|
177
|
+
hash: 608412555606104598
|
178
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
179
|
none: false
|
180
180
|
requirements:
|