fluent-plugin-mutate_filter 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/fluent-plugin-mutate_filter.gemspec +1 -1
- data/lib/fluent/plugin/filter_mutate.rb +13 -2
- data/lib/fluent/plugin_mixin/mutate_event.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f273d02df90c86edf77b7da2a423f69ae04ece2
|
4
|
+
data.tar.gz: 19aea04bbc065742d0c731ba8d0f82d8ae109c7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b77096cfe6a4789eea6edb6f854a961fcdef75f9c3334594311e5951d4bf0f500c9faa7d0a8b44bf46c72deaaec3d0be621ff82466faa86d8c81a31b1badaa6
|
7
|
+
data.tar.gz: 5f186b08d987b56058c1514cd752b99cd31b8a9d5cd1637d69fffa7423b59568d0f331f0b9a461c884f1329fb6dae1f61c0cb27b16cab2b9c32d386819283295
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Gem::Specification.new do |spec|
|
3
3
|
spec.name = "fluent-plugin-mutate_filter"
|
4
|
-
spec.version = "0.
|
4
|
+
spec.version = "0.2.0"
|
5
5
|
spec.authors = ["Jonathan Serafini"]
|
6
6
|
spec.email = ["jonathan@serafini.ca"]
|
7
7
|
spec.summary = %q{A mutate filter for Fluent which functions like Logstash.}
|
@@ -129,7 +129,7 @@ module Fluent
|
|
129
129
|
)
|
130
130
|
|
131
131
|
# Convert valid types
|
132
|
-
VALID_CONVERSIONS = %w(string integer float boolean)
|
132
|
+
VALID_CONVERSIONS = %w(string integer float boolean datetime)
|
133
133
|
|
134
134
|
# Convert helper method prefix
|
135
135
|
CONVERT_PREFIX = "convert_".freeze
|
@@ -179,6 +179,8 @@ module Fluent
|
|
179
179
|
# determines whether we should treat periods as field separators.
|
180
180
|
result = Fluent::PluginMixin::MutateEvent.
|
181
181
|
new(record, expand_nesting: @expand_nesting)
|
182
|
+
result.event_time = time.to_i
|
183
|
+
result.event_tag = tag
|
182
184
|
|
183
185
|
MUTATE_ACTIONS.each do |action|
|
184
186
|
begin
|
@@ -206,7 +208,11 @@ module Fluent
|
|
206
208
|
|
207
209
|
matches.each do |match|
|
208
210
|
reference_tag = match[0][2..-2]
|
209
|
-
reference_value =
|
211
|
+
reference_value = case reference_tag
|
212
|
+
when "event_time" then event.event_time.to_s
|
213
|
+
when "event_tag" then event.event_tag
|
214
|
+
else event.get(reference_tag.downcase).to_s
|
215
|
+
end
|
210
216
|
if reference_value.nil?
|
211
217
|
@log.error "failed to replace tag", field: reference_tag.downcase
|
212
218
|
reference_value = match.to_s
|
@@ -294,6 +300,11 @@ module Fluent
|
|
294
300
|
value.to_f
|
295
301
|
end
|
296
302
|
|
303
|
+
def convert_datetime(value)
|
304
|
+
value = convert_integer(value) if value.is_a?(String)
|
305
|
+
Time.at(value).to_datetime
|
306
|
+
end
|
307
|
+
|
297
308
|
def convert_boolean(value)
|
298
309
|
return true if value =~ TRUE_REGEX
|
299
310
|
return false if value.empty? || value =~ FALSE_REGEX
|
@@ -1,12 +1,17 @@
|
|
1
1
|
module Fluent
|
2
2
|
module PluginMixin
|
3
3
|
class MutateEvent < SimpleDelegator
|
4
|
-
def initialize(record, expand_nesting
|
4
|
+
def initialize(record, expand_nesting: true)
|
5
5
|
super(record)
|
6
6
|
@record = record
|
7
|
+
@event_time = nil
|
8
|
+
@event_tag = nil
|
7
9
|
@expand_nesting = expand_nesting
|
8
10
|
end
|
9
11
|
|
12
|
+
attr_accessor :event_time
|
13
|
+
attr_accessor :event_tag
|
14
|
+
|
10
15
|
def to_record
|
11
16
|
@record
|
12
17
|
end
|