fluent-plugin-json_expander 0.0.1.pre → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-json_expander.gemspec +1 -1
- data/lib/fluent/plugin/out_json_expander.rb +18 -14
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d583201256a49ab2c2ca48747f882c55aa3397fe
|
4
|
+
data.tar.gz: b91660f95dedaf77e44ba9b2490c0d245bc828f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69e2106ffe9668eadcc54f011cbfec61d250c6d4d1bccc280f9743ccf4b3e7eb20918616a87f24b35e806938bfc09b08e834c8208ea4bd2d25e2ecf4f3013546
|
7
|
+
data.tar.gz: 4137b0ec45ec23e2a9c39ca6e81c6808c1a91065091621c13de31145009539e5e9ee5ffd6bab85763449301f01a2cf02c6334404b2fd26b59b395e50827c22ff
|
@@ -43,13 +43,13 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
|
|
43
43
|
tag = tag[@removed_length..-1]
|
44
44
|
end
|
45
45
|
if @add_prefix
|
46
|
-
tag = tag.empty? ? (@added_prefix_string + tag)
|
46
|
+
tag = tag.empty? ? @add_prefix : (@added_prefix_string + tag)
|
47
47
|
end
|
48
48
|
|
49
49
|
es.each {|time, record|
|
50
|
-
output = new_output(record)
|
50
|
+
output, new_record = *new_output(record)
|
51
51
|
if output
|
52
|
-
dup_es = Fluent::ArrayEventStream.new([[time,
|
52
|
+
dup_es = Fluent::ArrayEventStream.new([[time, new_record]])
|
53
53
|
null_chain = Fluent::NullOutputChain.instance
|
54
54
|
output.emit(tag, dup_es, null_chain)
|
55
55
|
end
|
@@ -64,7 +64,8 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
|
|
64
64
|
t = @template
|
65
65
|
begin
|
66
66
|
@mutex.synchronize do
|
67
|
-
|
67
|
+
e, data = expand_elm(t, data)
|
68
|
+
if e
|
68
69
|
o = Fluent::Plugin.new_output(@subtype)
|
69
70
|
o.configure(e)
|
70
71
|
o.start
|
@@ -86,7 +87,7 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
|
|
86
87
|
o = nil
|
87
88
|
end
|
88
89
|
|
89
|
-
return o
|
90
|
+
return o, data
|
90
91
|
end
|
91
92
|
|
92
93
|
SCAN_DATA_RE = /\$\{data\[(?:[_a-zA-Z][_a-zA-Z0-9]*)\]\}/
|
@@ -100,11 +101,11 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
|
|
100
101
|
if !key_matched or !key_matched[0]
|
101
102
|
raise(Fluent::ConfigError, "[BUG] data matched in template, but could not find key name")
|
102
103
|
end
|
103
|
-
|
104
|
-
|
105
|
-
data
|
104
|
+
target = key_matched[0]
|
105
|
+
if @delete_used_key
|
106
|
+
data.delete(target) || on_empty_data(target, data)
|
106
107
|
else
|
107
|
-
data[
|
108
|
+
data[target] || on_empty_data(target, data)
|
108
109
|
end
|
109
110
|
end
|
110
111
|
attr[k] = v
|
@@ -113,14 +114,17 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
|
|
113
114
|
sub_elms = template.elements.map {|e| expand_elm(data) }
|
114
115
|
|
115
116
|
if @mark_errored
|
116
|
-
nil
|
117
|
+
return nil, nil
|
117
118
|
else
|
118
|
-
Fluent::Config::Element.new('instance', '', attr, sub_elms)
|
119
|
+
return Fluent::Config::Element.new('instance', '', attr, sub_elms), data
|
119
120
|
end
|
120
121
|
end
|
121
122
|
|
122
|
-
def
|
123
|
-
|
124
|
-
|
123
|
+
def on_empty_data(k, data)
|
124
|
+
if @handle_empty_as_error
|
125
|
+
log.error "Could not find value for `#{k}' in data #{data.inspect}, Fluentd skips this"
|
126
|
+
@mark_errored = true
|
127
|
+
end
|
128
|
+
""
|
125
129
|
end
|
126
130
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-json_expander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uchio KONDO
|
@@ -128,9 +128,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
130
|
requirements:
|
131
|
-
- - "
|
131
|
+
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
133
|
+
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
136
|
rubygems_version: 2.2.3
|