fluent-plugin-flume 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7572fd137da7ba6c6668e09fdb489ca58f417781
4
- data.tar.gz: ec492fdb5fadfaddf89a21ea4b78f76c126bcd05
3
+ metadata.gz: 4b78497ad732b1daed34f85264299c5f531b8862
4
+ data.tar.gz: 01d60de145ffe1f44c682aa74ca6448e596d8a9e
5
5
  SHA512:
6
- metadata.gz: b53cfe600d060d4537c2cac0b96b5cc4b020e9ad05b81b56e2bede3923836fb52612d7022cd6f90c64c211665c3499a07b1db8b97131188d19ef84b1c0fab1be
7
- data.tar.gz: 7287e3c0988a562da41eac18cbbd535265d738af90b61015c639601b43c8bddcee5c9d2d476f7c15239242431f8b604869d208bdb3b7b136683189cd2940bf2e
6
+ metadata.gz: 34fe016d453e36b285731ac4882ad4d2001702f56a65921017bef3c383bdf1894526520e7c869136d64d67ec9c43dcb5c0575e6630c8e216de3c754e23a441df
7
+ data.tar.gz: 779f483c0eeae828af4b693df7d54a525277961cfb6f421a27a92d673664ee0873cd382b18f0754d4733770c775edd766df435995a05e435cf1b6952dd8ac6a0
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Release 0.1.3 - 2016/10/25
2
+
3
+ * Add format parameter for formatter plugins support
4
+
1
5
  Release 0.1.2 - 2015/11/30
2
6
 
3
7
  * Updated thrift to 0.9.0
data/README.rdoc CHANGED
@@ -83,7 +83,7 @@ Use flume-ng-fluentd-sink[https://github.com/cosmo0920/flume-ng-fluentd-sink] to
83
83
 
84
84
  == Flume Output
85
85
 
86
- Please add the following configurations to fluent.conf. This allows fluentd to output its logs into another Flume server. Note that fluentd conveys semi-structured data while Flume conveys unstructured data. Thus the plugin translates semi-structured data into JSON data and conveys it to Flume.
86
+ Please add the following configurations to fluent.conf. This allows fluentd to output its logs into another Flume server. Note that fluentd conveys semi-structured data while Flume conveys unstructured data. Thus the plugin translates semi-structured data into JSON data by default and conveys it to Flume. The format can be adjusted via formatters.
87
87
 
88
88
  # Flume output
89
89
  <match *>
@@ -98,6 +98,8 @@ These options are supported.
98
98
  * port: port number (default: 35863)
99
99
  * timeout: thrift protocol timeout (default: 30)
100
100
  * remove_prefix: prefix string, removed from the tag (default: nil)
101
+ * format: The format of the thrift body (default: json)
102
+ * trim_nl: Trim new line from thrift body (default: true)
101
103
 
102
104
  == Contributors
103
105
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -15,6 +15,9 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
+
19
+ require 'fluent/input'
20
+
18
21
  module Fluent
19
22
 
20
23
  class FlumeInput < Input
@@ -15,6 +15,9 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
+
19
+ require 'fluent/output'
20
+
18
21
  module Fluent
19
22
 
20
23
  class FlumeOutput < BufferedOutput
@@ -25,6 +28,9 @@ class FlumeOutput < BufferedOutput
25
28
  config_param :timeout, :integer, :default => 30
26
29
  config_param :remove_prefix, :string, :default => nil
27
30
  config_param :default_category, :string, :default => 'unknown'
31
+ desc "The format of the thrift body. (default: json)"
32
+ config_param :format, :string, default: 'json'
33
+ config_param :trim_nl, :bool, default: true
28
34
 
29
35
  unless method_defined?(:log)
30
36
  define_method(:log) { $log }
@@ -42,7 +48,11 @@ class FlumeOutput < BufferedOutput
42
48
  def configure(conf)
43
49
  # override default buffer_chunk_limit
44
50
  conf['buffer_chunk_limit'] ||= '1m'
51
+
45
52
  super
53
+
54
+ @formatter = Plugin.new_formatter(@format)
55
+ @formatter.configure(conf)
46
56
  end
47
57
 
48
58
  def start
@@ -60,12 +70,12 @@ class FlumeOutput < BufferedOutput
60
70
 
61
71
  def format(tag, time, record)
62
72
  if @remove_prefix and
63
- ( (tag[0, @removed_length] == @removed_prefix_string and tag.length > @removed_length) or
64
- tag == @remove_prefix)
65
- [(tag[@removed_length..-1] || @default_category), time, record].to_msgpack
66
- else
67
- [tag, time, record].to_msgpack
73
+ ((tag[0, @removed_length] == @removed_prefix_string and tag.length > @removed_length) or tag == @remove_prefix)
74
+ tag = (tag[@removed_length..-1] || @default_category)
68
75
  end
76
+ fr = @formatter.format(tag, time, record)
77
+ fr.chomp! if @trim_nl
78
+ [tag, time, fr].to_msgpack
69
79
  end
70
80
 
71
81
  def write(chunk)
@@ -76,15 +86,15 @@ class FlumeOutput < BufferedOutput
76
86
  client = ThriftSourceProtocol::Client.new protocol
77
87
 
78
88
  count = 0
89
+ header = {}
79
90
  transport.open
80
91
  log.debug "thrift client opened: #{client}"
81
92
  begin
82
93
  chunk.msgpack_each { |tag, time, record|
83
- entry = ThriftFlumeEvent.new(:body => record.to_json.to_s.force_encoding('UTF-8'),
84
- :headers => {
85
- 'timestamp' => time.to_s,
86
- 'tag' => tag,
87
- })
94
+ header['timestamp'.freeze] = time.to_s
95
+ header['tag'.freeze] = tag
96
+ entry = ThriftFlumeEvent.new(:body => record.force_encoding('UTF-8'),
97
+ :headers => header)
88
98
  client.append entry
89
99
  count += 1
90
100
  }
@@ -13,7 +13,7 @@ class FlumeOutputTest < Test::Unit::TestCase
13
13
  ]
14
14
 
15
15
  def create_driver(conf=CONFIG, tag='test')
16
- Fluent::Test::BufferedOutputTestDriver.new(Fluent::FlumeOutput, tag)do
16
+ Fluent::Test::BufferedOutputTestDriver.new(Fluent::FlumeOutput, tag) do
17
17
  def write(chunk)
18
18
  chunk.read
19
19
  end
@@ -41,8 +41,9 @@ class FlumeOutputTest < Test::Unit::TestCase
41
41
  d = create_driver
42
42
  d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
43
43
  d.emit({"k21"=>"v21", "k22"=>"v22"}, time)
44
- d.expect_format [d.tag, time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
45
- d.expect_format [d.tag, time, {"k21"=>"v21", "k22"=>"v22"}].to_msgpack
44
+ puts ({"k11" => "v11", "k12" => "v12"}.to_json)
45
+ d.expect_format [d.tag, time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack
46
+ d.expect_format [d.tag, time, {"k21"=>"v21", "k22"=>"v22"}.to_json].to_msgpack
46
47
  d.run
47
48
 
48
49
  d = create_driver(CONFIG + %[
@@ -52,8 +53,8 @@ class FlumeOutputTest < Test::Unit::TestCase
52
53
 
53
54
  d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
54
55
  d.emit({"k21"=>"v21", "k22"=>"v22"}, time)
55
- d.expect_format ['flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
56
- d.expect_format ['flumeplugin', time, {"k21"=>"v21", "k22"=>"v22"}].to_msgpack
56
+ d.expect_format ['flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack
57
+ d.expect_format ['flumeplugin', time, {"k21"=>"v21", "k22"=>"v22"}.to_json].to_msgpack
57
58
  d.run
58
59
 
59
60
  d = create_driver(CONFIG + %[
@@ -61,7 +62,7 @@ class FlumeOutputTest < Test::Unit::TestCase
61
62
  ], 'xxx.test.flumeplugin')
62
63
  assert_equal 'xxx.test.flumeplugin', d.tag
63
64
  d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
64
- d.expect_format ['xxx.test.flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
65
+ d.expect_format ['xxx.test.flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack
65
66
  d.run
66
67
 
67
68
  d = create_driver(CONFIG + %[
@@ -69,7 +70,7 @@ class FlumeOutputTest < Test::Unit::TestCase
69
70
  ], 'test')
70
71
  assert_equal 'test', d.tag
71
72
  d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
72
- d.expect_format ['unknown', time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
73
+ d.expect_format ['unknown', time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack
73
74
  d.run
74
75
 
75
76
  d = create_driver(CONFIG + %[
@@ -78,8 +79,8 @@ class FlumeOutputTest < Test::Unit::TestCase
78
79
  assert_equal 'test.flumeplugin', d.tag
79
80
  d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
80
81
  d.emit({"k21"=>"v21", "k22"=>"v22"}, time)
81
- d.expect_format ['flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
82
- d.expect_format ['flumeplugin', time, {"k21"=>"v21", "k22"=>"v22"}].to_msgpack
82
+ d.expect_format ['flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack
83
+ d.expect_format ['flumeplugin', time, {"k21"=>"v21", "k22"=>"v22"}.to_json].to_msgpack
83
84
  d.run
84
85
  end
85
86
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-flume
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muga Nishizawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-01 00:00:00.000000000 Z
11
+ date: 2016-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.4.5.1
119
+ rubygems_version: 2.5.1
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Flume Input/Output plugin for Fluentd event collector