fluent-plugin-record-reformer 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 905ddbf4748a2a0609648bde025f49bc1959a475
4
- data.tar.gz: ee4120d718f07dde5793555fd48f9b67bbb89282
3
+ metadata.gz: 1bb8ef48e3b8c84c2c2f19875adff5570467dfe6
4
+ data.tar.gz: 028229752d4a6b8bcd5acfa0e3312d36c790838a
5
5
  SHA512:
6
- metadata.gz: c7a72c9c560f8aaf604d2840b53c8d931ee0f79fe57ecb4252f24b09e8d6c909ba6a36f11b2b3b717cefa0141e1187bb752930b17d07ffcb4fb4217207dcaf3a
7
- data.tar.gz: d8c2436af87363743160312d9e830548306343f5ef39bddeca89637efb03306e381ef13be082659a3ad60b3a00e6aa48979a0b5dc8bd27145ea118050c8d69a9
6
+ metadata.gz: fa6144cd1c31f3951333dfa64ab1f59c32c911781e2a3ce0b74a7f4cb185625f3285ea2995d548a16eefec4305889c0af6702b6a68212aef960df1403def71c5
7
+ data.tar.gz: b61672fcca95b5540377025ec387840dffb60fbbfe3cbfed812a760d3c1b441fd389213d0fe4288fffbb13a03936dd9aad1360e9ccb95614a953f615eeb7704b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.6.2 (2015/05/27)
2
+
3
+ Enhancements:
4
+
5
+ * Add `renew_time_key` option (thanks to @tagomoris)
6
+
1
7
  ## 0.6.1 (2015/05/10)
2
8
 
3
9
  Enhancements:
data/README.md CHANGED
@@ -90,6 +90,10 @@ This results in same, but please note that following option parameters are reser
90
90
 
91
91
  `renew_record true` creates an output record newly without extending (merging) the input record fields. Default is `false`.
92
92
 
93
+ - renew\_time\_key *string*
94
+
95
+ `renew_time_key foo` overwrite time of events with value of field `foo` if exist. The value of `foo` must be unix time.
96
+
93
97
  - keep_keys
94
98
 
95
99
  You may want to remain some record fields although you specify `renew_record true`. Then, specify record keys to be kept by a string separated by , (comma) like
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-record-reformer"
6
- gem.version = "0.6.1"
6
+ gem.version = "0.6.2"
7
7
  gem.authors = ["Naotoshi Seo"]
8
8
  gem.email = "sonots@gmail.com"
9
9
  gem.homepage = "https://github.com/sonots/fluent-plugin-record-reformer"
@@ -14,6 +14,7 @@ module Fluent
14
14
  config_param :remove_keys, :string, :default => nil
15
15
  config_param :keep_keys, :string, :default => nil
16
16
  config_param :renew_record, :bool, :default => false
17
+ config_param :renew_time_key, :string, :default => nil
17
18
  config_param :enable_ruby, :bool, :default => true # true for lower version compatibility
18
19
 
19
20
  BUILTIN_CONFIGURATIONS = %W(type tag output_tag remove_keys renew_record keep_keys enable_ruby)
@@ -92,7 +93,12 @@ module Fluent
92
93
  es.each {|time, record|
93
94
  last_record = record # for debug log
94
95
  new_tag, new_record = reform(@tag, time, record, placeholders)
95
- router.emit(new_tag, time, new_record) if new_tag
96
+ if new_tag
97
+ if @renew_time_key && new_record.has_key?(@renew_time_key)
98
+ time = new_record[@renew_time_key].to_i
99
+ end
100
+ router.emit(new_tag, time, new_record)
101
+ end
96
102
  }
97
103
  chain.next
98
104
  rescue => e
@@ -1,5 +1,6 @@
1
1
  require_relative 'helper'
2
2
  require 'rr'
3
+ require 'time'
3
4
  require 'timecop'
4
5
  require 'fluent/plugin/out_record_reformer'
5
6
 
@@ -138,6 +139,22 @@ class RecordReformerOutputTest < Test::Unit::TestCase
138
139
  end
139
140
  end
140
141
 
142
+ test 'renew_time_key' do
143
+ times = [ Time.local(2,2,3,4,5,2010,nil,nil,nil,nil), Time.local(3,2,3,4,5,2010,nil,nil,nil,nil) ]
144
+ config = <<EOC
145
+ tag reformed.${tag}
146
+ enable_ruby true
147
+ message ${Time.parse(message).to_i}
148
+ renew_time_key message
149
+ EOC
150
+ msgs = times.map{|t| t.to_s }
151
+ emits = emit(config, use_v1, msgs)
152
+ emits.each_with_index do |(tag, time, record), i|
153
+ assert_equal("reformed.#{@tag}", tag)
154
+ assert_equal(times[i].to_i, time)
155
+ end
156
+ end
157
+
141
158
  test 'keep_keys' do
142
159
  config = %[tag reformed.${tag}\nrenew_record true\nkeep_keys eventType0,message]
143
160
  msgs = ['1', '2']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-record-reformer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-10 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubyforge_project:
150
- rubygems_version: 2.4.5
150
+ rubygems_version: 2.2.2
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: Fluentd plugin to add or replace fields of a event record