fluent-plugin-reassemble 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/fluent-plugin-reassemble.gemspec +1 -1
- data/lib/fluent/plugin/out_reassemble.rb +45 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmM2MjgwYTFjM2U5ZWU1OGU1MmFiMTYyNzExY2UzYjA5MGRkZTBlOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmI5ODI1MmE5MmI0ZWMwMzI4ZDNkNTdjNWFjMGJiYmUzOGM4NDY1NQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDUyMjRhZDdlZDlmZDZkZTMxZDlkZGY0NDk0ZGQ0YjExY2ZiNWU4YzcxM2Nl
|
10
|
+
N2Y5NDVkM2QyMGYzMzE0ZTJmYzkxZDY4OGMxNDZkM2RhOWRlODYxYmZiNzA0
|
11
|
+
ODYwODhjMjJlOTkyYjY2YjZkMGEyZGEwMjE2YzIwNTkxMmJkZmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTkyYTQ4OGZmZWE1YmFkNDk5YmEwNDRiZTAzMWQ5NmQxMTBlNGMwNDc2ZDU3
|
14
|
+
ZGU3M2E2MmEyN2VjZDc5NzlmMjE0ODA2YjNjYzdkM2MwMTZhNzA2MmI2NDcx
|
15
|
+
NDQyOTk3ZDE3ZjFkZjI3ZWE0ZjdlNGE4MjUyYzljZDk5MDM0MWI=
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-reassemble"
|
4
|
-
gem.version = "0.0.
|
4
|
+
gem.version = "0.0.6"
|
5
5
|
gem.authors = ["moaikids"]
|
6
6
|
gem.licenses = ["Apache License Version 2.0"]
|
7
7
|
gem.summary = %q{Re-assemble a stream data for Fluentd}
|
@@ -6,6 +6,9 @@ module Fluent
|
|
6
6
|
Fluent::Plugin.register_output('reassemble', self)
|
7
7
|
config_param :output_tag, :string, :default => nil
|
8
8
|
config_param :assemble, :string, :default => nil
|
9
|
+
config_param :expand_extract_key, :string, :default => nil
|
10
|
+
config_param :expand_replaced_key, :string, :default => nil
|
11
|
+
config_param :expand_operation, :string, :default => nil
|
9
12
|
config_param :null_to_null, :bool, :default => false
|
10
13
|
config_param :null_to_empty, :bool, :default => false
|
11
14
|
config_param :datetime_format, :string, :default => '%Y/%m/%d %H:%M:%S'
|
@@ -50,24 +53,52 @@ module Fluent
|
|
50
53
|
def emit(tag, es, chain)
|
51
54
|
chain.next
|
52
55
|
es.each {|time,record|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
56
|
+
if @expand_extract_key.nil?
|
57
|
+
json = reassemble(record)
|
58
|
+
Fluent::Engine.emit(@output_tag, time, json)
|
59
|
+
else
|
60
|
+
replaced_key = @expand_replaced_key
|
61
|
+
if @expand_replaced_key.nil? || @expand_replaced_key.empty?
|
62
|
+
replaced_key = @expand_extract_key
|
63
|
+
end
|
64
|
+
operation = @expand_operation
|
65
|
+
traversed = traverse(record, @expand_extract_key)
|
66
|
+
if traversed
|
67
|
+
traversed.each { |r|
|
68
|
+
json = reassemble(record)
|
69
|
+
val = convert(r, operation)
|
70
|
+
if !(val.nil?)
|
71
|
+
json[replaced_key] = val
|
72
|
+
elsif @null_to_null
|
73
|
+
json[replaced_key] = nil
|
74
|
+
elsif @null_to_empty
|
75
|
+
json[replaced_key] = ""
|
76
|
+
end
|
77
|
+
Fluent::Engine.emit(@output_tag, time, json)
|
78
|
+
}
|
65
79
|
end
|
66
|
-
|
67
|
-
Fluent::Engine.emit(@output_tag, time, json)
|
80
|
+
end
|
68
81
|
}
|
69
82
|
end
|
70
83
|
|
84
|
+
def reassemble(record)
|
85
|
+
json = {}
|
86
|
+
@reassemble_conf.each { |conf|
|
87
|
+
extract_key = conf[:extract]
|
88
|
+
replaced_key = conf[:replace]
|
89
|
+
operation = conf[:operation]
|
90
|
+
val = convert(traverse(record, extract_key), operation)
|
91
|
+
if !(val.nil?)
|
92
|
+
json[replaced_key] = val
|
93
|
+
elsif @null_to_null
|
94
|
+
json[replaced_key] = nil
|
95
|
+
elsif @null_to_empty
|
96
|
+
json[replaced_key] = ""
|
97
|
+
end
|
98
|
+
}
|
99
|
+
return json
|
100
|
+
end
|
101
|
+
|
71
102
|
def traverse(data, key)
|
72
103
|
val = data
|
73
104
|
key.split('.').each{ |k|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-reassemble
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- moaikids
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|