fluent-plugin-flatten 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/fluent-plugin-flatten.gemspec +1 -1
- data/lib/fluent/plugin/out_flatten.rb +11 -6
- data/test/plugin/test_out_flatten.rb +63 -14
- metadata +13 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4a8ba7f4d84e3a2bef454ea068925b670238f2f5
|
4
|
+
data.tar.gz: d87803fbf7ca88eaad5265ece23ed36a5e5d12f7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06c0fdcadf8a1e2e2eebedf2b530c76a454f081651ac194cfcb77814bbe096a28ae0bd055122c1b53f28951834a7a3e9d25c0f1d0e9b0f962dac680ebb5cad16
|
7
|
+
data.tar.gz: e7220024b630036da3bb1be8c79bef88c5f2e4df2d55d5da3cdfb7eada8c86969b17c1ec2c7a5ad32c2aae726e758eaffcb3109be40faf98cb58585b16f3496e
|
@@ -7,8 +7,9 @@ module Fluent
|
|
7
7
|
|
8
8
|
Fluent::Plugin.register_output('flatten', self)
|
9
9
|
|
10
|
-
config_param :key,
|
11
|
-
config_param :inner_key,
|
10
|
+
config_param :key, :string
|
11
|
+
config_param :inner_key, :string, :default => 'value'
|
12
|
+
config_param :parse_json, :bool, :default => true
|
12
13
|
|
13
14
|
def configure(conf)
|
14
15
|
super
|
@@ -45,10 +46,14 @@ module Fluent
|
|
45
46
|
hash = nil
|
46
47
|
|
47
48
|
begin
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
if parse_json
|
50
|
+
# XXX work-around
|
51
|
+
# fluentd seems to escape json value excessively
|
52
|
+
json = record[key].gsub(/\\"/, '"')
|
53
|
+
hash = JSON.parse(json)
|
54
|
+
else
|
55
|
+
hash = record[key]
|
56
|
+
end
|
52
57
|
rescue JSON::ParserError
|
53
58
|
return flattened
|
54
59
|
end
|
@@ -37,6 +37,21 @@ class FlattenOutputTest < Test::Unit::TestCase
|
|
37
37
|
assert_equal /^test\./, d2.instance.remove_tag_prefix
|
38
38
|
assert_equal 'value_for_flat_key', d2.instance.inner_key
|
39
39
|
|
40
|
+
# when `parse_json` is false
|
41
|
+
d3 = create_driver(%[
|
42
|
+
key foo
|
43
|
+
add_tag_prefix flattened.
|
44
|
+
remove_tag_prefix test.
|
45
|
+
inner_key value_for_flat_key
|
46
|
+
parse_json false
|
47
|
+
])
|
48
|
+
|
49
|
+
assert_equal 'foo', d3.instance.key
|
50
|
+
assert_equal 'flattened.', d3.instance.add_tag_prefix
|
51
|
+
assert_equal /^test\./, d3.instance.remove_tag_prefix
|
52
|
+
assert_equal 'value_for_flat_key', d3.instance.inner_key
|
53
|
+
assert_equal false, d3.instance.parse_json
|
54
|
+
|
40
55
|
# when mandatory keys not set
|
41
56
|
assert_raise(Fluent::ConfigError) do
|
42
57
|
create_driver(%[
|
@@ -67,30 +82,64 @@ class FlattenOutputTest < Test::Unit::TestCase
|
|
67
82
|
end
|
68
83
|
|
69
84
|
def test_emit
|
70
|
-
|
85
|
+
# test1 default config
|
86
|
+
d1 = create_driver
|
87
|
+
|
88
|
+
d1.run do
|
89
|
+
d1.emit( 'foo' => '{"bar" : "baz"}', 'hoge' => 'fuga' )
|
90
|
+
d1.emit( 'foo' => '{"bar" : {"qux" : "quux", "hoe" : "poe" }, "baz" : "bazz" }', 'hoge' => 'fuga' )
|
91
|
+
end
|
92
|
+
emits1 = d1.emits
|
93
|
+
|
94
|
+
assert_equal 4, emits1.count
|
95
|
+
|
96
|
+
# ["flattened.foo.bar", 1354689632, {"value"=>"baz"}]
|
97
|
+
assert_equal 'flattened.foo.bar', emits1[0][0]
|
98
|
+
assert_equal 'baz', emits1[0][2]['value']
|
99
|
+
|
100
|
+
# ["flattened.foo.bar.qux", 1354689632, {"value"=>"quux"}]
|
101
|
+
assert_equal 'flattened.foo.bar.qux', emits1[1][0]
|
102
|
+
assert_equal 'quux', emits1[1][2]['value']
|
103
|
+
|
104
|
+
# ["flattened.foo.bar.hoe", 1354689632, {"value"=>"poe"}]
|
105
|
+
assert_equal 'flattened.foo.bar.hoe', emits1[2][0]
|
106
|
+
assert_equal 'poe', emits1[2][2]['value']
|
107
|
+
|
108
|
+
# ["flattened.foo.bar.baz", 1354689632, {"value"=>"bazz"}]
|
109
|
+
assert_equal 'flattened.foo.baz', emits1[3][0]
|
110
|
+
assert_equal 'bazz', emits1[3][2]['value']
|
71
111
|
|
72
|
-
|
73
|
-
|
74
|
-
|
112
|
+
# test2 parse_json is set false
|
113
|
+
d2 = create_driver(%[
|
114
|
+
key foo
|
115
|
+
add_tag_prefix flattened.
|
116
|
+
remove_tag_prefix test.
|
117
|
+
parse_json false
|
118
|
+
])
|
119
|
+
|
120
|
+
d2.run do
|
121
|
+
d2.emit( 'foo' => {'bar' => 'baz'}, 'hoge' => 'fuga' )
|
122
|
+
d2.emit( 'foo' => {'bar' => {'qux' => 'quux', 'hoe' => 'poe' }, 'baz' => 'bazz' }, 'hoge' => 'fuga' )
|
75
123
|
end
|
76
|
-
|
124
|
+
emits2 = d2.emits
|
77
125
|
|
78
|
-
assert_equal 4,
|
126
|
+
assert_equal 4, emits2.count
|
79
127
|
|
80
128
|
# ["flattened.foo.bar", 1354689632, {"value"=>"baz"}]
|
81
|
-
assert_equal 'flattened.foo.bar',
|
82
|
-
assert_equal 'baz',
|
129
|
+
assert_equal 'flattened.foo.bar', emits2[0][0]
|
130
|
+
assert_equal 'baz', emits2[0][2]['value']
|
83
131
|
|
84
132
|
# ["flattened.foo.bar.qux", 1354689632, {"value"=>"quux"}]
|
85
|
-
assert_equal 'flattened.foo.bar.qux',
|
86
|
-
assert_equal 'quux',
|
133
|
+
assert_equal 'flattened.foo.bar.qux', emits2[1][0]
|
134
|
+
assert_equal 'quux', emits2[1][2]['value']
|
87
135
|
|
88
136
|
# ["flattened.foo.bar.hoe", 1354689632, {"value"=>"poe"}]
|
89
|
-
assert_equal 'flattened.foo.bar.hoe',
|
90
|
-
assert_equal 'poe',
|
137
|
+
assert_equal 'flattened.foo.bar.hoe', emits2[2][0]
|
138
|
+
assert_equal 'poe', emits2[2][2]['value']
|
91
139
|
|
92
140
|
# ["flattened.foo.bar.baz", 1354689632, {"value"=>"bazz"}]
|
93
|
-
assert_equal 'flattened.foo.baz',
|
94
|
-
assert_equal 'bazz',
|
141
|
+
assert_equal 'flattened.foo.baz', emits2[3][0]
|
142
|
+
assert_equal 'bazz', emits2[3][2]['value']
|
143
|
+
|
95
144
|
end
|
96
145
|
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-flatten
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kentaro Kuribayashi
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: fluentd
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: fluentd
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Fluentd plugin to extract values for nested key paths and re-emit them
|
@@ -78,27 +71,26 @@ files:
|
|
78
71
|
- test/test_helper.rb
|
79
72
|
homepage: http://github.com/kentaro/fluent-plugin-flatten
|
80
73
|
licenses: []
|
74
|
+
metadata: {}
|
81
75
|
post_install_message:
|
82
76
|
rdoc_options: []
|
83
77
|
require_paths:
|
84
78
|
- lib
|
85
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
80
|
requirements:
|
88
|
-
- -
|
81
|
+
- - '>='
|
89
82
|
- !ruby/object:Gem::Version
|
90
83
|
version: '0'
|
91
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
85
|
requirements:
|
94
|
-
- -
|
86
|
+
- - '>='
|
95
87
|
- !ruby/object:Gem::Version
|
96
88
|
version: '0'
|
97
89
|
requirements: []
|
98
90
|
rubyforge_project:
|
99
|
-
rubygems_version:
|
91
|
+
rubygems_version: 2.0.2
|
100
92
|
signing_key:
|
101
|
-
specification_version:
|
93
|
+
specification_version: 4
|
102
94
|
summary: Fluentd plugin to extract values for nested key paths and re-emit them as
|
103
95
|
flat tag/record pairs.
|
104
96
|
test_files:
|