fluent-plugin-filter-kv-parser 0.0.5 → 0.0.6

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
  SHA256:
3
- metadata.gz: 17b0a7a0a397bf519d5a7d7688e6a56a7ce775ae1e4a67e13ecd52b1cc3a67d7
4
- data.tar.gz: e7c98aada2fbd67bea7d25944df3dda9767147543bbc2dde01d43e778d386103
3
+ metadata.gz: 8932148ec7a3bfaa0a6241823bda594b85d5a91b24dca0156fb2e7497e4f5eef
4
+ data.tar.gz: 810626b5c05a84a382719b9bb40393ee3f901b7d3d9b8366114e1b8633e08621
5
5
  SHA512:
6
- metadata.gz: 7f45b2af88c16bb14832dd974b57ac0bc4bbeaf74e876be73f9a00f1bc7a42026f2980cc6910cef59d6b3711f08ab971d47ead6ffaecc8b9ab6ba13403e64ebf
7
- data.tar.gz: 14d852b72aaded4f57511cc2599df34fe21893aa45f52da09dba33a49b03cbb18e54892e520131cce2f381da94c0eaacbe9d6704845b53648b2d502ec0d81e85
6
+ metadata.gz: 89089861029085470ada61bb7d34bee99d33c46b3d089b56fc840c4f2881a479fab0a31a0f6ea663171d1c3bb5e7eface8cd5e92cd0c57b4769179e55c6ba610
7
+ data.tar.gz: 8bba97ee414b53f06222af5f6f8bad5ef89e4e2538896a8f9e0a3b5c239ef594f796a7da033843cac4e62f1207eb38591a42827147757c6adfc38f9fdb8cf3b4
data/README.md CHANGED
@@ -27,6 +27,7 @@ gem install fluent-plugin-filter-kv-parser
27
27
  kv_delimiter_chart '='
28
28
  filtered_keys akey,bkey,ckey
29
29
  filtered_keys_regex /^sub_[a-zA-Z_0-9]+/
30
+ filter_out_lines_without_keys false
30
31
  </filter>
31
32
 
32
33
  <match **>
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-filter-kv-parser"
6
- s.version = "0.0.5"
6
+ s.version = "0.0.6"
7
7
  s.authors = ["Al-waleed Shihadeh"]
8
8
  s.email = ["wshihadeh.dev@gmail.com"]
9
9
  s.homepage = "https://github.com/wshihadeh/fluent-plugin-filter-kv-parser.git"
@@ -7,6 +7,7 @@ module Fluent
7
7
 
8
8
  config_param :key, :string, default: 'log'
9
9
  config_param :remove_key, :bool, default: false
10
+ config_param :filter_out_lines_without_keys, :bool, default: false
10
11
  config_param :use_regex, :bool, default: false
11
12
  config_param :remove_prefix, :string, default: ''
12
13
  config_param :keys_delimiter, :string, default: '/\s+/'
@@ -39,9 +40,11 @@ module Fluent
39
40
  def filter(tag, time, record)
40
41
  return if record[@key].nil?
41
42
 
42
- log_line = extract_log_line record[@key]
43
+ keys = extracted_keys(extract_log_line(record[@key]))
43
44
 
44
- record.merge! extracted_keys(log_line)
45
+ return if @filter_out_lines_without_keys && keys.empty?
46
+
47
+ record.merge! keys
45
48
  record.tap { |r| r.delete(@key) if @remove_key }.compact
46
49
  end
47
50
 
@@ -188,4 +188,28 @@ class KeyValueFilterTest < Test::Unit::TestCase
188
188
  assert_equal "0", filtered['sub_key']
189
189
  assert_equal false, filtered.key?("log")
190
190
  end
191
+
192
+ test 'test_filter_out_lines_without_keys' do
193
+ d = create_driver(%[
194
+ key log
195
+ remove_key true
196
+ use_regex true
197
+ filtered_keys_regex /^sub_[a-zA-Z_0-9]+/
198
+ filter_out_lines_without_keys true
199
+ ])
200
+ msg = {
201
+ 'time' => '2013-02-12 22:01:15 UTC',
202
+ 'log' => "akey=10 bkey=11 ckey=11",
203
+ }
204
+
205
+ msg2 = {
206
+ 'time' => '2013-02-12 22:01:15 UTC',
207
+ 'log' => "Start Request to test lines without any keys",
208
+ }
209
+ filtered = filter(d, [msg, msg2])
210
+
211
+ assert_equal 1, filtered.count
212
+ assert_equal 4, filtered.first[2].count
213
+ assert_equal "10", filtered.first[2]['akey']
214
+ end
191
215
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-filter-kv-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Al-waleed Shihadeh