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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 639b39fa06bf5d5d826365e15e8e2e924d7125c1
4
- data.tar.gz: 1fdcec678bfcfa15b204568b3d8f0d964e3ff847
3
+ metadata.gz: 0f273d02df90c86edf77b7da2a423f69ae04ece2
4
+ data.tar.gz: 19aea04bbc065742d0c731ba8d0f82d8ae109c7c
5
5
  SHA512:
6
- metadata.gz: 04719d07a13157dd3d995245ffee06b4d490b647891d804eaf86465572c8643d22321a2a2f6d52e46a7fc77c9d73767f0ec28d328d098f067cdfeccb41cf54b0
7
- data.tar.gz: 3a3d2e481fd40e4f06888e2b88fda88bdd51358982e477f5bf7986dba431f5e3081c620e0b3e3239c2fd8470f6dabeb2c3a100c25cf5be0203ee17d90de192c6
6
+ metadata.gz: 3b77096cfe6a4789eea6edb6f854a961fcdef75f9c3334594311e5951d4bf0f500c9faa7d0a8b44bf46c72deaaec3d0be621ff82466faa86d8c81a31b1badaa6
7
+ data.tar.gz: 5f186b08d987b56058c1514cd752b99cd31b8a9d5cd1637d69fffa7423b59568d0f331f0b9a461c884f1329fb6dae1f61c0cb27b16cab2b9c32d386819283295
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ v2.0.0
4
+ -------------
5
+ * Fix MutateEvent initializer bug
6
+ * Add support for event_tag and event_time substitutions %{event_time}
7
+ * Add a datetime conversion
8
+
3
9
  v0.1.2
4
10
  -------------
5
11
  * Resolve bug in gsub attributes
@@ -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.1.2"
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 = event.get(reference_tag.downcase).to_s
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 = true)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-mutate_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Serafini