fluent-plugin-record_splitter 0.1.5 → 0.2.0
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 +4 -4
- data/Gemfile +1 -1
- data/README.md +9 -2
- data/Rakefile +1 -2
- data/VERSION +1 -1
- data/fluent-plugin-record_splitter.gemspec +14 -12
- data/lib/fluent/plugin/out_record_splitter.rb +58 -48
- data/test/test_out_record_splitter.rb +55 -41
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd96d0a95cd0fea74f83b3696a5f613a6317871f
|
4
|
+
data.tar.gz: 776b7ed3e78ebfc77ac57afe9ae1aac0080841d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40689124abcdb86913e46d1eae027a2527b908f3f67ce63f65ed5b7092b63dfc9e5e46d0a579621a550badbaba000764592ed8e34a8854e71fddb66b9f8f093f
|
7
|
+
data.tar.gz: e015c41e2be6f89c13e80fa671064946a0ee30a14b965dd2915be7bde0101dfce2aac6ede69fe58ef2b5af2f075f191873314953fe3290d79be3985e9e6994d6
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,13 @@ fluent-plugin-record_splitter
|
|
3
3
|
|
4
4
|
Output split array plugin for fluentd.
|
5
5
|
|
6
|
+
## Dependence
|
7
|
+
|
8
|
+
- td-agent v2(fluentd ~> 0.12.0)
|
9
|
+
- fluent-plugin-record_splitter < 0.1.6
|
10
|
+
- td-agnet v3(fluentd ~> 0.14.0)
|
11
|
+
- fluent-plugin-record_splitter >= 0.1.6
|
12
|
+
|
6
13
|
## Installation
|
7
14
|
|
8
15
|
```
|
@@ -13,7 +20,7 @@ gem install fluent-plugin-record_splitter
|
|
13
20
|
|
14
21
|
<match pattern>
|
15
22
|
type record_splitter
|
16
|
-
tag foo.
|
23
|
+
tag foo.split
|
17
24
|
split_key target_field
|
18
25
|
keep_keys ["common","general"]
|
19
26
|
</match>
|
@@ -35,7 +42,7 @@ another configuration
|
|
35
42
|
|
36
43
|
<match pattern>
|
37
44
|
type record_splitter
|
38
|
-
tag foo.
|
45
|
+
tag foo.split
|
39
46
|
split_key target_field
|
40
47
|
keep_other_key true
|
41
48
|
remove_keys ["general"]
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -1,23 +1,25 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
4
|
|
4
5
|
Gem::Specification.new do |gem|
|
5
|
-
gem.name =
|
6
|
-
gem.description =
|
7
|
-
gem.homepage =
|
6
|
+
gem.name = 'fluent-plugin-record_splitter'
|
7
|
+
gem.description = 'output split array plugin for fluentd'
|
8
|
+
gem.homepage = 'https://github.com/ixixi/fluent-plugin-record_splitter'
|
8
9
|
gem.summary = gem.description
|
9
|
-
gem.version = File.read(
|
10
|
-
gem.authors = [
|
11
|
-
gem.email =
|
10
|
+
gem.version = File.read('VERSION').strip
|
11
|
+
gem.authors = ['Yuri Odagiri']
|
12
|
+
gem.email = 'ixixizko@gmail.com'
|
12
13
|
gem.has_rdoc = false
|
13
14
|
gem.license = 'MIT'
|
14
15
|
gem.files = `git ls-files`.split("\n")
|
15
16
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
17
18
|
gem.require_paths = ['lib']
|
18
19
|
|
19
|
-
gem.add_dependency
|
20
|
-
gem.add_dependency
|
21
|
-
gem.add_dependency
|
22
|
-
gem.add_development_dependency
|
20
|
+
gem.add_dependency 'fluentd', ['>= 0.14.0', '< 2']
|
21
|
+
gem.add_dependency 'fluent-mixin-config-placeholders', '>= 0.3.0'
|
22
|
+
gem.add_dependency 'fluent-mixin-rewrite-tag-name'
|
23
|
+
gem.add_development_dependency 'rake', '>= 0.9.2'
|
24
|
+
gem.add_development_dependency 'test-unit'
|
23
25
|
end
|
@@ -1,60 +1,70 @@
|
|
1
|
+
require 'fluent/plugin/output'
|
1
2
|
require 'fluent/mixin/config_placeholders'
|
2
3
|
require 'fluent/mixin/rewrite_tag_name'
|
3
4
|
|
4
5
|
module Fluent
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if @keep_other_key and not @keep_keys.empty?
|
27
|
-
raise Fluent::ConfigError, 'Cannot set keep_keys when keep_other_key is true.'
|
28
|
-
end
|
29
|
-
if not @keep_other_key and not @remove_keys.empty?
|
30
|
-
raise Fluent::ConfigError, 'Cannot set remove_keys when keep_other_key is false.'
|
31
|
-
end
|
32
|
-
if not @tag and not @remove_prefix and not @add_prefix
|
33
|
-
raise Fluent::ConfigError, "missing both of remove_prefix and add_prefix"
|
34
|
-
end
|
35
|
-
if @tag and (@remove_prefix or @add_prefix)
|
36
|
-
raise Fluent::ConfigError, "both of tag and remove_prefix/add_prefix must not be specified"
|
6
|
+
module Plugin
|
7
|
+
class RecordSplitterOutput < Output
|
8
|
+
Fluent::Plugin.register_output('record_splitter', self)
|
9
|
+
|
10
|
+
config_param :tag, :string
|
11
|
+
config_param :remove_prefix, :string, default: nil
|
12
|
+
config_param :add_prefix, :string, default: nil
|
13
|
+
config_param :split_key, :string
|
14
|
+
config_param :keep_other_key, :bool, default: false
|
15
|
+
config_param :keep_keys, :array, default: []
|
16
|
+
config_param :remove_keys, :array, default: []
|
17
|
+
|
18
|
+
include SetTagKeyMixin
|
19
|
+
include Fluent::Mixin::ConfigPlaceholders
|
20
|
+
include Fluent::HandleTagNameMixin
|
21
|
+
include Fluent::Mixin::RewriteTagName
|
22
|
+
|
23
|
+
helpers :event_emitter
|
24
|
+
|
25
|
+
def multi_workers_ready?
|
26
|
+
true
|
37
27
|
end
|
38
|
-
end
|
39
28
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
29
|
+
def configure(conf)
|
30
|
+
super
|
31
|
+
if !@keep_keys.empty? && !@remove_keys.empty?
|
32
|
+
raise Fluent::ConfigError, 'Cannot set both keep_keys and remove_keys.'
|
33
|
+
end
|
34
|
+
if @keep_other_key && !@keep_keys.empty?
|
35
|
+
raise Fluent::ConfigError, 'Cannot set keep_keys when keep_other_key is true.'
|
36
|
+
end
|
37
|
+
if !@keep_other_key && !@remove_keys.empty?
|
38
|
+
raise Fluent::ConfigError, 'Cannot set remove_keys when keep_other_key is false.'
|
48
39
|
end
|
49
|
-
if
|
50
|
-
|
40
|
+
if !@tag && !@remove_prefix && !@add_prefix
|
41
|
+
raise Fluent::ConfigError, 'missing both of remove_prefix and add_prefix'
|
42
|
+
end
|
43
|
+
if @tag && (@remove_prefix || @add_prefix)
|
44
|
+
raise Fluent::ConfigError, 'both of tag and remove_prefix/add_prefix must not be specified'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def process(tag, es)
|
49
|
+
emit_tag = tag.dup
|
50
|
+
|
51
|
+
es.each do |time, record|
|
52
|
+
filter_record(emit_tag, time, record)
|
53
|
+
|
54
|
+
if @keep_other_key
|
55
|
+
common = record.reject { |key, _value| key == @split_key || @remove_keys.include?(key) }
|
56
|
+
else
|
57
|
+
common = record.select { |key, _value| @keep_keys.include?(key) }
|
58
|
+
end
|
59
|
+
|
60
|
+
next unless record.key?(@split_key)
|
61
|
+
|
62
|
+
record[@split_key].each do |v|
|
51
63
|
v.merge!(common) unless common.empty?
|
52
|
-
router.emit(emit_tag, time, v
|
53
|
-
|
64
|
+
router.emit(emit_tag, time, v)
|
65
|
+
end
|
54
66
|
end
|
55
|
-
|
56
|
-
chain.next
|
67
|
+
end
|
57
68
|
end
|
58
|
-
|
59
69
|
end
|
60
70
|
end
|
@@ -1,92 +1,106 @@
|
|
1
1
|
require 'fluent/test'
|
2
|
+
require 'fluent/test/driver/output'
|
3
|
+
require 'test/unit'
|
2
4
|
require 'fluent/plugin/out_record_splitter'
|
3
5
|
|
4
|
-
|
5
6
|
class RecordSplitterOutputTest < Test::Unit::TestCase
|
6
7
|
def setup
|
7
8
|
Fluent::Test.setup
|
8
9
|
end
|
9
10
|
|
10
|
-
CONFIG = %
|
11
|
-
type record_splitter
|
12
|
-
tag foo.splitted
|
13
|
-
]
|
11
|
+
CONFIG = %().freeze
|
14
12
|
|
15
13
|
def create_driver(conf = CONFIG)
|
16
|
-
Fluent::Test::
|
14
|
+
Fluent::Test::Driver::Output
|
15
|
+
.new(Fluent::Plugin::RecordSplitterOutput)
|
16
|
+
.configure(conf)
|
17
|
+
end
|
18
|
+
|
19
|
+
def event_time
|
20
|
+
Time.parse('2017-06-01 00:11:22 UTC').to_i
|
17
21
|
end
|
18
22
|
|
19
23
|
def test_split_default
|
20
|
-
d = create_driver %
|
21
|
-
type record_splitter
|
22
|
-
tag foo.
|
24
|
+
d = create_driver %(
|
25
|
+
@type record_splitter
|
26
|
+
tag foo.split
|
23
27
|
split_key target_field
|
24
|
-
|
28
|
+
)
|
25
29
|
|
26
|
-
d.run do
|
27
|
-
d.
|
30
|
+
d.run(default_tag: 'test') do
|
31
|
+
d.feed(event_time,
|
32
|
+
'other' => 'foo',
|
33
|
+
'target_field' => [{ 'k1' => 'v1' }, { 'k2' => 'v2' }])
|
28
34
|
end
|
29
35
|
|
30
36
|
assert_equal [
|
31
|
-
{'k1'=>'v1'},
|
32
|
-
{'k2'=>'v2'}
|
33
|
-
], d.
|
37
|
+
['foo.split', event_time, { 'k1' => 'v1' }],
|
38
|
+
['foo.split', event_time, { 'k2' => 'v2' }]
|
39
|
+
], d.events
|
34
40
|
end
|
35
41
|
|
36
|
-
|
37
42
|
def test_split_with_keep_other_key
|
38
|
-
d = create_driver %
|
43
|
+
d = create_driver %(
|
39
44
|
type record_splitter
|
40
|
-
tag foo.
|
45
|
+
tag foo.split
|
41
46
|
split_key target_field
|
42
47
|
keep_other_key true
|
43
|
-
|
48
|
+
)
|
44
49
|
|
45
|
-
d.run do
|
46
|
-
d.
|
50
|
+
d.run(default_tag: 'test') do
|
51
|
+
d.feed(event_time,
|
52
|
+
'common' => 'c', 'general' => 'g', 'other' => 'foo',
|
53
|
+
'target_field' => [{ 'k1' => 'v1' }, { 'k2' => 'v2' }])
|
47
54
|
end
|
48
55
|
|
49
56
|
assert_equal [
|
50
|
-
|
51
|
-
|
52
|
-
|
57
|
+
['foo.split', event_time,
|
58
|
+
{ 'common' => 'c', 'general' => 'g', 'other' => 'foo', 'k1' => 'v1' }],
|
59
|
+
['foo.split', event_time,
|
60
|
+
{ 'common' => 'c', 'general' => 'g', 'other' => 'foo', 'k2' => 'v2' }]
|
61
|
+
], d.events
|
53
62
|
end
|
54
63
|
|
55
64
|
def test_split_with_keep_other_key_and_remove_key
|
56
|
-
d = create_driver %
|
65
|
+
d = create_driver %(
|
57
66
|
type record_splitter
|
58
|
-
tag foo.
|
67
|
+
tag foo.split
|
59
68
|
split_key target_field
|
60
69
|
keep_other_key true
|
61
70
|
remove_keys ["general","other"]
|
62
|
-
|
71
|
+
)
|
63
72
|
|
64
|
-
d.run do
|
65
|
-
d.
|
73
|
+
d.run(default_tag: 'test') do
|
74
|
+
d.feed(event_time,
|
75
|
+
'common' => 'c', 'general' => 'g', 'other' => 'foo',
|
76
|
+
'target_field' => [{ 'k1' => 'v1' }, { 'k2' => 'v2' }])
|
66
77
|
end
|
67
78
|
|
68
79
|
assert_equal [
|
69
|
-
{'common'=>'c','k1'=>'v1'},
|
70
|
-
{'common'=>'c','k2'=>'v2'}
|
71
|
-
], d.
|
80
|
+
['foo.split', event_time, { 'common' => 'c', 'k1' => 'v1' }],
|
81
|
+
['foo.split', event_time, { 'common' => 'c', 'k2' => 'v2' }]
|
82
|
+
], d.events
|
72
83
|
end
|
73
84
|
|
74
85
|
def test_split_with_keep_keys
|
75
|
-
d = create_driver %
|
86
|
+
d = create_driver %(
|
76
87
|
type record_splitter
|
77
|
-
tag foo.
|
88
|
+
tag foo.split
|
78
89
|
split_key target_field
|
79
90
|
keep_keys ["common","general"]
|
80
|
-
|
91
|
+
)
|
81
92
|
|
82
|
-
d.run do
|
83
|
-
d.
|
93
|
+
d.run(default_tag: 'test') do
|
94
|
+
d.feed(event_time,
|
95
|
+
'common' => 'c', 'general' => 'g', 'other' => 'foo',
|
96
|
+
'target_field' => [{ 'k1' => 'v1' }, { 'k2' => 'v2' }])
|
84
97
|
end
|
85
98
|
|
86
99
|
assert_equal [
|
87
|
-
|
88
|
-
|
89
|
-
|
100
|
+
['foo.split', event_time,
|
101
|
+
{ 'common' => 'c', 'general' => 'g', 'k1' => 'v1' }],
|
102
|
+
['foo.split', event_time,
|
103
|
+
{ 'common' => 'c', 'general' => 'g', 'k2' => 'v2' }]
|
104
|
+
], d.events
|
90
105
|
end
|
91
|
-
|
92
106
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-record_splitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuri Odagiri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.14.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.14.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2'
|
@@ -72,6 +72,20 @@ dependencies:
|
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 0.9.2
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: test-unit
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
75
89
|
description: output split array plugin for fluentd
|
76
90
|
email: ixixizko@gmail.com
|
77
91
|
executables: []
|
@@ -106,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
120
|
version: '0'
|
107
121
|
requirements: []
|
108
122
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.11
|
110
124
|
signing_key:
|
111
125
|
specification_version: 4
|
112
126
|
summary: output split array plugin for fluentd
|