fluent-plugin-flatten-hash2 0.4.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +130 -0
- data/Rakefile +13 -0
- data/fluent-plugin-flatten-hash.gemspec +23 -0
- data/lib/fluent/plugin/filter_flatten_hash.rb +20 -0
- data/lib/fluent/plugin/flatten_hash_util.rb +19 -0
- data/lib/fluent/plugin/out_flatten_hash.rb +39 -0
- data/test/helper.rb +14 -0
- data/test/plugin/test_filter_flatten_array.rb +47 -0
- data/test/plugin/test_filter_flatten_hash.rb +57 -0
- data/test/plugin/test_out_flatten_hash.rb +119 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1488508ac8d7f4c339c9af41072f190bf0ad2879
|
4
|
+
data.tar.gz: d2b1edcb65458dd8c58f6e8472ab5fd39a1ea3bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82c105739c320e068389f5a33098bd30d27c647238cb9159a08efea4c971e7531d6a4ce752443fac60d051b39ce4da81dbfca010d1243c1d69bfb6a3b4fbf07b
|
7
|
+
data.tar.gz: 3dfd7833e9941a9fab39c4ecc37f997498e7ba5495798b8d04b5aab0e2db6a03b26fa83a765ebfe82fb2e23e232e23377d2399319b6d031bdda43e265ae97bc3
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Masahiro Sano
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
# fluent-plugin-flatten-hash, a plugin for [Fluentd](http://fluentd.org)
|
2
|
+
|
3
|
+
[](https://travis-ci.org/kazegusuri/fluent-plugin-flatten-hash)
|
4
|
+
|
5
|
+
A fluentd plugin to flatten nested hash structure as a flat record with unique keys generated by its path for each values.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'fluent-plugin-flatten-hash'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fluent-plugin-flatten-hash
|
20
|
+
|
21
|
+
## Configuration
|
22
|
+
|
23
|
+
fluent-plugin-flatten-hash supports both Output and Filter plugin.
|
24
|
+
|
25
|
+
### Output
|
26
|
+
|
27
|
+
You can set a configuration like below:
|
28
|
+
|
29
|
+
```
|
30
|
+
<match message>
|
31
|
+
type flatten_hash
|
32
|
+
add_tag_prefix flattened.
|
33
|
+
separator _
|
34
|
+
</match>
|
35
|
+
```
|
36
|
+
|
37
|
+
In this configuration, if you get a following nested/complex message:
|
38
|
+
|
39
|
+
```js
|
40
|
+
{
|
41
|
+
"message":{
|
42
|
+
"today":"good day",
|
43
|
+
"tommorow":{
|
44
|
+
"is":{
|
45
|
+
"a":{
|
46
|
+
"bad":"day"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
},
|
51
|
+
"days":[
|
52
|
+
"2013/08/24",
|
53
|
+
"2013/08/25"
|
54
|
+
]
|
55
|
+
}
|
56
|
+
```
|
57
|
+
|
58
|
+
The message is flattened like below:
|
59
|
+
|
60
|
+
```js
|
61
|
+
{
|
62
|
+
"message_today":"good day",
|
63
|
+
"message_tommorow_is_a_bad":"day",
|
64
|
+
"days_0":"2013/08/24",
|
65
|
+
"days_1":"2013/08/25"
|
66
|
+
}
|
67
|
+
```
|
68
|
+
|
69
|
+
In order to prevent arrays from being indexed, you can use a configuration like below:
|
70
|
+
|
71
|
+
```
|
72
|
+
<match message>
|
73
|
+
type flatten_hash
|
74
|
+
add_tag_prefix flattened.
|
75
|
+
separator _
|
76
|
+
flatten_array false
|
77
|
+
</match>
|
78
|
+
```
|
79
|
+
|
80
|
+
Using the same input, you'll instead end up with a message flattened like below:
|
81
|
+
|
82
|
+
```js
|
83
|
+
{
|
84
|
+
"message_today":"good day",
|
85
|
+
"message_tommorow_is_a_bad":"day",
|
86
|
+
"days":["2013/08/24","2013/08/25"]
|
87
|
+
}
|
88
|
+
```
|
89
|
+
|
90
|
+
|
91
|
+
### Filter
|
92
|
+
|
93
|
+
You can set a configuration like below:
|
94
|
+
|
95
|
+
```
|
96
|
+
<filter message>
|
97
|
+
type flatten_hash
|
98
|
+
separator _
|
99
|
+
</filter>
|
100
|
+
|
101
|
+
<match message>
|
102
|
+
type stdout
|
103
|
+
</match>
|
104
|
+
```
|
105
|
+
|
106
|
+
## Contributing
|
107
|
+
|
108
|
+
1. Fork it
|
109
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
110
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
111
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
112
|
+
5. Create new Pull Request
|
113
|
+
|
114
|
+
### Mixins
|
115
|
+
|
116
|
+
* HandleTagNameMixin
|
117
|
+
|
118
|
+
## Copyright
|
119
|
+
|
120
|
+
<table>
|
121
|
+
<tr>
|
122
|
+
<td>Author</td><td>Masahiro Sano <sabottenda@gmail.com></td>
|
123
|
+
</tr>
|
124
|
+
<tr>
|
125
|
+
<td>Copyright</td><td>Copyright (c) 2013- Masahiro Sano</td>
|
126
|
+
</tr>
|
127
|
+
<tr>
|
128
|
+
<td>License</td><td>MIT License</td>
|
129
|
+
</tr>
|
130
|
+
</table>
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-flatten-hash2"
|
7
|
+
spec.version = "0.4.2"
|
8
|
+
spec.authors = ["Masahiro Sano"]
|
9
|
+
spec.email = ["sabottenda@gmail.com"]
|
10
|
+
spec.description = %q{A fluentd plugin to flatten nested hash structure as a flat record}
|
11
|
+
spec.summary = %q{A fluentd plugin to flatten nested hash structure as a flat record}
|
12
|
+
spec.homepage = "https://github.com/take-the-interview/fluent-plugin-flatten-hash"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.has_rdoc = false
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "fluentd", ["~> 0.12.0"]
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "test-unit"
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Fluent
|
2
|
+
class FlattenHashFilter < Filter
|
3
|
+
Plugin.register_filter('flatten_hash', self)
|
4
|
+
|
5
|
+
require_relative 'flatten_hash_util'
|
6
|
+
include FlattenHashUtil
|
7
|
+
|
8
|
+
config_param :separator, :string, :default => '.'
|
9
|
+
config_param :flatten_array, :bool, :default => true
|
10
|
+
config_param :remove_tag_prefix, :string, :default => ''
|
11
|
+
|
12
|
+
def configure(conf)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def filter(tag, time, record)
|
17
|
+
flatten_record(record, [])
|
18
|
+
end
|
19
|
+
end if defined?(Filter)
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fluent
|
2
|
+
module FlattenHashUtil
|
3
|
+
def flatten_record(record, prefix)
|
4
|
+
ret = {}
|
5
|
+
if record.is_a? Hash
|
6
|
+
record.each { |key, value|
|
7
|
+
ret.merge! flatten_record(value, prefix + [key.to_s])
|
8
|
+
}
|
9
|
+
elsif record.is_a? Array and @flatten_array
|
10
|
+
record.each_with_index { |elem, index|
|
11
|
+
ret.merge! flatten_record(elem, prefix + [index.to_s])
|
12
|
+
}
|
13
|
+
else
|
14
|
+
return {prefix.join(@separator).gsub(@remove_tag_prefix, "") => record}
|
15
|
+
end
|
16
|
+
ret
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fluent
|
2
|
+
class FlattenHashOutput < Output
|
3
|
+
include Fluent::HandleTagNameMixin
|
4
|
+
Fluent::Plugin.register_output('flatten_hash', self)
|
5
|
+
|
6
|
+
require_relative 'flatten_hash_util'
|
7
|
+
include FlattenHashUtil
|
8
|
+
|
9
|
+
config_param :tag, :string, :default => nil
|
10
|
+
config_param :separator, :string, :default => '.'
|
11
|
+
config_param :flatten_array, :bool, :default => true
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure(conf)
|
18
|
+
super
|
19
|
+
if (!@tag &&
|
20
|
+
!remove_tag_prefix &&
|
21
|
+
!remove_tag_suffix &&
|
22
|
+
!add_tag_prefix &&
|
23
|
+
!add_tag_suffix )
|
24
|
+
raise ConfigError, "out_flatten_hash: No tag parameters are set"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def emit(tag, es, chain)
|
29
|
+
tag = @tag || tag
|
30
|
+
es.each do |time, record|
|
31
|
+
record = flatten_record(record, [])
|
32
|
+
t = tag.dup
|
33
|
+
filter_record(t, time, record)
|
34
|
+
router.emit(t, time, record)
|
35
|
+
end
|
36
|
+
chain.next
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'fluent/plugin/filter_flatten_hash'
|
3
|
+
|
4
|
+
class FlattenHashFlattenArrayFilterTest < Test::Unit::TestCase
|
5
|
+
include Fluent
|
6
|
+
|
7
|
+
BASE_CONFIG = %[
|
8
|
+
type flatten_hash
|
9
|
+
]
|
10
|
+
CONFIG = BASE_CONFIG + %[
|
11
|
+
add_tag_prefix flattened
|
12
|
+
flatten_array false
|
13
|
+
]
|
14
|
+
|
15
|
+
def setup
|
16
|
+
Fluent::Test.setup
|
17
|
+
@time = Fluent::Engine.now
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_driver(conf = '')
|
21
|
+
Test::FilterTestDriver.new(FlattenHashFilter).configure(conf, true)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_flatten_record_flatten_array_false
|
25
|
+
d = create_driver CONFIG
|
26
|
+
es = Fluent::MultiEventStream.new
|
27
|
+
now = Fluent::Engine.now
|
28
|
+
|
29
|
+
d.run do
|
30
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
31
|
+
d.emit({"message" => {'foo' => 'bar', 'hoge' => 'fuga'}})
|
32
|
+
d.emit({"message" => {'nest' => {'foo' => 'bar'}}})
|
33
|
+
d.emit({"message" => {'nest' => {'nest' => {'foo' => 'bar'}}}})
|
34
|
+
d.emit({"message" => {'array' => ['foo', 'bar']}})
|
35
|
+
d.emit({"message" => {'array' => [{'foo' => 'bar'}, {'hoge' => 'fuga'}]}})
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_equal [
|
39
|
+
{"message.foo" => "bar"},
|
40
|
+
{"message.foo" => "bar", "message.hoge" => "fuga"},
|
41
|
+
{"message.nest.foo" => "bar"},
|
42
|
+
{"message.nest.nest.foo" => "bar"},
|
43
|
+
{"message.array"=>["foo", "bar"]},
|
44
|
+
{"message.array"=>[{"foo"=>"bar"}, {"hoge"=>"fuga"}]},
|
45
|
+
], d.filtered_as_array.map{|x| x[2]}
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'fluent/plugin/filter_flatten_hash'
|
3
|
+
|
4
|
+
class FlattenHashFilterTest < Test::Unit::TestCase
|
5
|
+
include Fluent
|
6
|
+
|
7
|
+
BASE_CONFIG = %[
|
8
|
+
type flatten_hash
|
9
|
+
]
|
10
|
+
CONFIG = BASE_CONFIG + %[
|
11
|
+
add_tag_prefix flattened
|
12
|
+
]
|
13
|
+
|
14
|
+
def setup
|
15
|
+
Fluent::Test.setup
|
16
|
+
@time = Fluent::Engine.now
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_driver(conf = '')
|
20
|
+
Test::FilterTestDriver.new(FlattenHashFilter).configure(conf, true)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_flatten_record
|
24
|
+
d = create_driver
|
25
|
+
es = Fluent::MultiEventStream.new
|
26
|
+
now = Fluent::Engine.now
|
27
|
+
|
28
|
+
d.run do
|
29
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
30
|
+
d.emit({"message" => {'foo' => 'bar', 'hoge' => 'fuga'}})
|
31
|
+
d.emit({"message" => {'nest' => {'foo' => 'bar'}}})
|
32
|
+
d.emit({"message" => {'nest' => {'nest' => {'foo' => 'bar'}}}})
|
33
|
+
d.emit({"message" => {'array' => ['foo', 'bar']}})
|
34
|
+
d.emit({"message" => {'array' => [{'foo' => 'bar'}, {'hoge' => 'fuga'}]}})
|
35
|
+
end
|
36
|
+
|
37
|
+
assert_equal [
|
38
|
+
{"message.foo" => "bar"},
|
39
|
+
{"message.foo" => "bar", "message.hoge" => "fuga"},
|
40
|
+
{"message.nest.foo" => "bar"},
|
41
|
+
{"message.nest.nest.foo" => "bar"},
|
42
|
+
{"message.array.0" => "foo", "message.array.1" => "bar"},
|
43
|
+
{"message.array.0.foo" => "bar", "message.array.1.hoge" => "fuga"},
|
44
|
+
], d.filtered_as_array.map{|x| x[2]}
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_separator
|
48
|
+
d = create_driver CONFIG + %[separator /]
|
49
|
+
|
50
|
+
d.run do
|
51
|
+
d.emit({"message" => {'nest' => {'foo' => 'bar'}}})
|
52
|
+
end
|
53
|
+
assert_equal [
|
54
|
+
{"message/nest/foo" => "bar"},
|
55
|
+
], d.filtered_as_array.map{|x| x[2]}
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'fluent/plugin/out_flatten_hash'
|
3
|
+
|
4
|
+
class FlattenHashOutputTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
BASE_CONFIG = %[
|
10
|
+
type flatten_hash
|
11
|
+
]
|
12
|
+
CONFIG = BASE_CONFIG + %[
|
13
|
+
add_tag_prefix flattened
|
14
|
+
]
|
15
|
+
|
16
|
+
def create_driver(conf = CONFIG, tag='test')
|
17
|
+
Fluent::Test::OutputTestDriver.new(Fluent::FlattenHashOutput, tag).configure(conf)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_configure
|
21
|
+
assert_raise(Fluent::ConfigError) {
|
22
|
+
create_driver(BASE_CONFIG)
|
23
|
+
}
|
24
|
+
assert_nothing_raised(Fluent::ConfigError) {
|
25
|
+
create_driver(BASE_CONFIG + %[
|
26
|
+
tag hoge
|
27
|
+
])
|
28
|
+
}
|
29
|
+
assert_nothing_raised(Fluent::ConfigError) {
|
30
|
+
create_driver(BASE_CONFIG + %[
|
31
|
+
add_tag_prefix hoge
|
32
|
+
])
|
33
|
+
}
|
34
|
+
assert_nothing_raised(Fluent::ConfigError) {
|
35
|
+
create_driver(BASE_CONFIG + %[
|
36
|
+
add_tag_suffix hoge
|
37
|
+
])
|
38
|
+
}
|
39
|
+
assert_nothing_raised(Fluent::ConfigError) {
|
40
|
+
create_driver(BASE_CONFIG + %[
|
41
|
+
remove_tag_prefix hoge
|
42
|
+
])
|
43
|
+
}
|
44
|
+
assert_nothing_raised(Fluent::ConfigError) {
|
45
|
+
create_driver(BASE_CONFIG + %[
|
46
|
+
remove_tag_suffix hoge
|
47
|
+
])
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_flatten_record
|
52
|
+
d = create_driver
|
53
|
+
|
54
|
+
d.run do
|
55
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
56
|
+
d.emit({"message" => {'foo' => 'bar', 'hoge' => 'fuga'}})
|
57
|
+
d.emit({"message" => {'nest' => {'foo' => 'bar'}}})
|
58
|
+
d.emit({"message" => {'nest' => {'nest' => {'foo' => 'bar'}}}})
|
59
|
+
d.emit({"message" => {'array' => ['foo', 'bar']}})
|
60
|
+
d.emit({"message" => {'array' => [{'foo' => 'bar'}, {'hoge' => 'fuga'}]}})
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_equal [
|
64
|
+
{"message.foo" => "bar"},
|
65
|
+
{"message.foo" => "bar", "message.hoge" => "fuga"},
|
66
|
+
{"message.nest.foo" => "bar"},
|
67
|
+
{"message.nest.nest.foo" => "bar"},
|
68
|
+
{"message.array.0" => "foo", "message.array.1" => "bar"},
|
69
|
+
{"message.array.0.foo" => "bar", "message.array.1.hoge" => "fuga"},
|
70
|
+
], d.records
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_separator
|
74
|
+
d = create_driver CONFIG + %[separator /]
|
75
|
+
|
76
|
+
d.run do
|
77
|
+
d.emit({"message" => {'nest' => {'foo' => 'bar'}}})
|
78
|
+
end
|
79
|
+
|
80
|
+
assert_equal [
|
81
|
+
{"message/nest/foo" => "bar"},
|
82
|
+
], d.records
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_emit_with_add_tag_prefix
|
86
|
+
d = create_driver BASE_CONFIG + %[
|
87
|
+
add_tag_prefix flattened.
|
88
|
+
]
|
89
|
+
d.run do
|
90
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
91
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
92
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
93
|
+
end
|
94
|
+
emits = d.emits
|
95
|
+
emits.each do |e|
|
96
|
+
assert_equal 'flattened.test', e[0]
|
97
|
+
assert_equal 'bar', e[2]["message.foo"]
|
98
|
+
end
|
99
|
+
assert_equal 3, emits.count
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_emit_with_remove_tag_prefix
|
103
|
+
tag = 'prefix.prefix.test'
|
104
|
+
d = create_driver BASE_CONFIG + %[
|
105
|
+
remove_tag_prefix prefix.
|
106
|
+
], tag
|
107
|
+
d.run do
|
108
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
109
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
110
|
+
d.emit({'message' => {'foo' => 'bar'}})
|
111
|
+
end
|
112
|
+
emits = d.emits
|
113
|
+
emits.each do |e|
|
114
|
+
assert_equal 'prefix.test', e[0]
|
115
|
+
assert_equal 'bar', e[2]["message.foo"]
|
116
|
+
end
|
117
|
+
assert_equal 3, emits.count
|
118
|
+
end
|
119
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-flatten-hash2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masahiro Sano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.12.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.12.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A fluentd plugin to flatten nested hash structure as a flat record
|
56
|
+
email:
|
57
|
+
- sabottenda@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- fluent-plugin-flatten-hash.gemspec
|
69
|
+
- lib/fluent/plugin/filter_flatten_hash.rb
|
70
|
+
- lib/fluent/plugin/flatten_hash_util.rb
|
71
|
+
- lib/fluent/plugin/out_flatten_hash.rb
|
72
|
+
- test/helper.rb
|
73
|
+
- test/plugin/test_filter_flatten_array.rb
|
74
|
+
- test/plugin/test_filter_flatten_hash.rb
|
75
|
+
- test/plugin/test_out_flatten_hash.rb
|
76
|
+
homepage: https://github.com/take-the-interview/fluent-plugin-flatten-hash
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.5.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: A fluentd plugin to flatten nested hash structure as a flat record
|
100
|
+
test_files:
|
101
|
+
- test/helper.rb
|
102
|
+
- test/plugin/test_filter_flatten_array.rb
|
103
|
+
- test/plugin/test_filter_flatten_hash.rb
|
104
|
+
- test/plugin/test_out_flatten_hash.rb
|