fluent-plugin-mutate_filter 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-mutate_filter.gemspec +1 -1
- data/lib/fluent/plugin/filter_mutate.rb +14 -22
- data/lib/fluent/plugin/mixin/mutate_event.rb +16 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f746bd9c44d86ef7ab074a10776185edd537fb420d0cdef9c4f73ae7caa043
|
4
|
+
data.tar.gz: baeed48ef9eced0336745871771a724ebcd759e48f09f700b367a60abe0af97c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1bc65b2293d7bd5bacd2141f6ab9c9c1986c01f9a7bbe687636daef2fe5cc86765b674a6d56131b6e7b36e61ec85044c872e484fc5c101510d9079850d1c125
|
7
|
+
data.tar.gz: 9a79a1e2cb37ffbc1c04690fde427f8a995b61f0008ba94a843ba9975ce5ae37e1be73fe432c06b73c563507874e9b5d16cb8a3d8e8be10f0291615cdc3fae08
|
@@ -4,8 +4,8 @@ require "fluent/plugin/mixin/mutate_event"
|
|
4
4
|
|
5
5
|
module Fluent
|
6
6
|
module Plugin
|
7
|
-
class
|
8
|
-
Fluent::Plugin.register_filter("
|
7
|
+
class MutateFilter2 < Fluent::Plugin::Filter
|
8
|
+
Fluent::Plugin.register_filter("mutate2", self)
|
9
9
|
|
10
10
|
# Treat periods as nested field names
|
11
11
|
config_param :expand_nesting, :bool, default: true
|
@@ -171,31 +171,27 @@ module Fluent
|
|
171
171
|
def expand_references(event, string)
|
172
172
|
new_string = ''
|
173
173
|
|
174
|
-
|
175
|
-
matches = string.scan(TEMPLATE_TAG_REGEXP).map{|m| $~}
|
176
|
-
|
177
|
-
matches.each do |match|
|
174
|
+
while match = string.match(TEMPLATE_TAG_REGEXP) do
|
178
175
|
reference_tag = match[0][2..-2]
|
179
176
|
reference_value = case reference_tag
|
180
177
|
when "event_time" then event.event_time.to_s
|
181
178
|
when "event_tag" then event.event_tag
|
182
179
|
else event.get(reference_tag.downcase).to_s
|
183
180
|
end
|
184
|
-
|
181
|
+
|
182
|
+
if reference_value == ""
|
185
183
|
@log.error "failed to replace tag", field: reference_tag.downcase
|
186
184
|
reference_value = match.to_s
|
187
185
|
end
|
188
186
|
|
189
187
|
start = match.offset(0).first
|
190
|
-
new_string << string[
|
188
|
+
new_string << string[0..(start-1)] if start > 0
|
191
189
|
new_string << reference_value
|
192
|
-
position = match.offset(0).last
|
193
|
-
end
|
194
190
|
|
195
|
-
|
196
|
-
new_string << string[position..-1]
|
191
|
+
string = string[match.offset(0).last..-1]
|
197
192
|
end
|
198
193
|
|
194
|
+
new_string << string
|
199
195
|
new_string
|
200
196
|
end
|
201
197
|
|
@@ -205,30 +201,26 @@ module Fluent
|
|
205
201
|
def expand_environment(event, string)
|
206
202
|
new_string = ''
|
207
203
|
|
208
|
-
|
209
|
-
matches = string.scan(ENVIRONMENT_TAG_REGEXP).map{|m| $~}
|
210
|
-
|
211
|
-
matches.each do |match|
|
204
|
+
while match = string.match(ENVIRONMENT_TAG_REGEXP) do
|
212
205
|
reference_tag = match[0][3..-2]
|
213
206
|
reference_value = case reference_tag
|
214
207
|
when "hostname" then Socket.gethostname
|
215
208
|
else ENV[reference_tag]
|
216
209
|
end
|
217
|
-
|
210
|
+
|
211
|
+
if reference_value == ""
|
218
212
|
@log.error "failed to replace tag", field: reference_tag
|
219
213
|
reference_value = match.to_s
|
220
214
|
end
|
221
215
|
|
222
216
|
start = match.offset(0).first
|
223
|
-
new_string << string[
|
217
|
+
new_string << string[0..(start-1)] if start > 0
|
224
218
|
new_string << reference_value
|
225
|
-
position = match.offset(0).last
|
226
|
-
end
|
227
219
|
|
228
|
-
|
229
|
-
new_string << string[position..-1]
|
220
|
+
string = string[match.offset(0).last..-1]
|
230
221
|
end
|
231
222
|
|
223
|
+
new_string << string
|
232
224
|
new_string
|
233
225
|
end
|
234
226
|
|
@@ -29,9 +29,22 @@ module Fluent
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def prune
|
32
|
-
delete_proc = proc do |
|
33
|
-
v
|
34
|
-
|
32
|
+
delete_proc = proc do |*args|
|
33
|
+
v = args[-1]
|
34
|
+
|
35
|
+
if v.respond_to?(:delete_if)
|
36
|
+
v.delete_if(&delete_proc)
|
37
|
+
end
|
38
|
+
|
39
|
+
if v.respond_to?(:strip)
|
40
|
+
v = v.strip
|
41
|
+
end
|
42
|
+
|
43
|
+
if v.respond_to?(:empty?) and v.empty?
|
44
|
+
v = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
v.nil?
|
35
48
|
end
|
36
49
|
|
37
50
|
@record.delete_if(&delete_proc)
|