fluent-plugin-record-modifier 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7ce747c7583be63187340e9cb3c115a33c70088b
4
+ data.tar.gz: 073fe2a881f23665cf21a249c79c8027f69cda67
5
+ SHA512:
6
+ metadata.gz: 108c4bf2ea859c94beeabc8ad82f53a15f9328ab813c5ebd56e5d3996988bfd86ca2125be7370038b003a4be2d51345542d34f3f6f2eabe25f84257bdcdd80a7
7
+ data.tar.gz: 21de6cfad5274f31fc72f883c4bd6aabf1bfbb07e7e78c066d82ecb72cf5b75955d0a0ec8acf5015cccdf75778acae334d87c712974e11b816f57d0826a21a90
data/.travis.yml CHANGED
@@ -4,10 +4,15 @@ rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
6
  - 2.0.0
7
- - rbx-19mode
7
+ - ruby-head
8
+ - rbx-2.1.1
8
9
 
9
10
  branches:
10
11
  only:
11
12
  - master
12
13
 
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: rbx-2.1.1
17
+
13
18
  script: bundle exec rake test
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ Release 0.1.3 - 2014/04/16
2
+
3
+ * Add remove_keys option to remove needless fields from record
4
+ https://github.com/repeatedly/fluent-plugin-record-modifier#remove_keys
5
+
6
+
1
7
  Release 0.1.2 - 2013/11/22
2
8
 
3
9
  * Add char_encoding parameter to handle charactor encoding in event record
data/README.md CHANGED
@@ -52,6 +52,32 @@ But an user sometimes processes the logs depends on their requirements, e.g. han
52
52
  </match>
53
53
  ```
54
54
 
55
+ ### remove_keys
56
+
57
+ The logs include needless record keys in some cases.
58
+ You can remove it by using `remove_keys` parameter.
59
+
60
+ ```conf
61
+ <match pattern>
62
+ type record_modifier
63
+
64
+ # remove key1 and key2 keys from record
65
+ remove_keys key1,key2
66
+ </match>
67
+ ```
68
+
69
+ If following record is passed:
70
+
71
+ ```js
72
+ {"key1":"hoge", "key2":"foo", "key3":"bar"}
73
+ ```
74
+
75
+ then you got new record like below:
76
+
77
+ ```js
78
+ {"key3":"bar"}
79
+ ```
80
+
55
81
  ### Mixins
56
82
 
57
83
  * [SetTagKeyMixin](https://github.com/fluent/fluentd/blob/master/lib/fluent/mixin.rb#L181)
@@ -63,8 +89,6 @@ But an user sometimes processes the logs depends on their requirements, e.g. han
63
89
 
64
90
  * Use HandleTagNameMixin to keep original tag
65
91
 
66
- * Remove record field
67
-
68
92
  * Replace record value
69
93
 
70
94
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.email = "repeatedly@gmail.com"
12
12
  gem.has_rdoc = false
13
13
  #gem.platform = Gem::Platform::RUBY
14
+ gem.license = 'MIT'
14
15
  gem.files = `git ls-files`.split("\n")
15
16
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
17
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -6,11 +6,12 @@ module Fluent
6
6
 
7
7
  config_param :tag, :string
8
8
  config_param :char_encoding, :string, :default => nil
9
+ config_param :remove_keys, :string, :default => nil
9
10
 
10
11
  include SetTagKeyMixin
11
12
  include Fluent::Mixin::ConfigPlaceholders
12
13
 
13
- BUILTIN_CONFIGURATIONS = %W(type tag include_tag_key tag_key char_encoding)
14
+ BUILTIN_CONFIGURATIONS = %W(type tag include_tag_key tag_key char_encoding remove_keys)
14
15
 
15
16
  def configure(conf)
16
17
  super
@@ -38,6 +39,10 @@ module Fluent
38
39
  define_method(:change_encoding, m)
39
40
  end
40
41
  end
42
+
43
+ if @remove_keys
44
+ @remove_keys = @remove_keys.split(',').map {|e| e.strip }
45
+ end
41
46
  end
42
47
 
43
48
  def emit(tag, es, chain)
@@ -56,6 +61,12 @@ module Fluent
56
61
  record[k] = v
57
62
  }
58
63
 
64
+ if @remove_keys
65
+ @remove_keys.each { |v|
66
+ record.delete(v)
67
+ }
68
+ end
69
+
59
70
  record = change_encoding(record) if @char_encoding
60
71
  record
61
72
  end
@@ -15,6 +15,7 @@ class RecordModifierOutputTest < Test::Unit::TestCase
15
15
  foo bar
16
16
  include_tag_key
17
17
  tag_key included_tag
18
+ remove_keys hoge
18
19
  ]
19
20
 
20
21
  def create_driver(conf = CONFIG)
@@ -79,4 +80,34 @@ class RecordModifierOutputTest < Test::Unit::TestCase
79
80
 
80
81
  assert_equal [{"k" => 'v'.force_encoding('cp932')}], d.records
81
82
  end
83
+
84
+ def test_remove_one_key
85
+ d = create_driver %[
86
+ type record_modifier
87
+
88
+ tag foo.filtered
89
+ remove_keys k1
90
+ ]
91
+
92
+ d.run do
93
+ d.emit("k1" => 'v', "k2" => 'v')
94
+ end
95
+
96
+ assert_equal [{"k2" => 'v'}], d.records
97
+ end
98
+
99
+ def test_remove_multiple_keys
100
+ d = create_driver %[
101
+ type record_modifier
102
+
103
+ tag foo.filtered
104
+ remove_keys k1, k2, k3
105
+ ]
106
+
107
+ d.run do
108
+ d.emit("k1" => 'v', "k2" => 'v', "k4" => 'v')
109
+ end
110
+
111
+ assert_equal [{"k4" => 'v'}], d.records
112
+ end
82
113
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-record-modifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Masahiro Nakagawa
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-22 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fluentd
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: fluent-mixin-config-placeholders
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,17 +41,15 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.9.2
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 0.9.2
62
55
  description: Output filter plugin for modifying each event record
@@ -75,34 +68,28 @@ files:
75
68
  - lib/fluent/plugin/out_record_modifier.rb
76
69
  - test/out_record_modifier.rb
77
70
  homepage: https://github.com/repeatedly/fluent-plugin-record-modifier
78
- licenses: []
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
79
74
  post_install_message:
80
75
  rdoc_options: []
81
76
  require_paths:
82
77
  - lib
83
78
  required_ruby_version: !ruby/object:Gem::Requirement
84
- none: false
85
79
  requirements:
86
- - - ! '>='
80
+ - - '>='
87
81
  - !ruby/object:Gem::Version
88
82
  version: '0'
89
- segments:
90
- - 0
91
- hash: -3676841215308348521
92
83
  required_rubygems_version: !ruby/object:Gem::Requirement
93
- none: false
94
84
  requirements:
95
- - - ! '>='
85
+ - - '>='
96
86
  - !ruby/object:Gem::Version
97
87
  version: '0'
98
- segments:
99
- - 0
100
- hash: -3676841215308348521
101
88
  requirements: []
102
89
  rubyforge_project:
103
- rubygems_version: 1.8.23
90
+ rubygems_version: 2.0.2
104
91
  signing_key:
105
- specification_version: 3
92
+ specification_version: 4
106
93
  summary: Output filter plugin for modifying each event record
107
94
  test_files:
108
95
  - test/out_record_modifier.rb