fluent-plugin-filter-kv-parser 0.0.7 → 0.0.9

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: caba515d5a8c6695dbcf8260e35b17a334b3f0bd52ae0a69c806b7328bfe3ec8
4
- data.tar.gz: 66d598cdcc9e239c31d3ea75beec7482eaec99b6ac47c1b8a6a1f33b73fb10e2
3
+ metadata.gz: a03fd43ca0868a32f5f9b2fb708b0dbbeba01213f7cb6c14cba269dbcb0b4b35
4
+ data.tar.gz: 3370ceff8ef70d6ae8084beb43019f222212a179614a235c0b4fec9a278116d5
5
5
  SHA512:
6
- metadata.gz: 0f5e88578e8de5411a2b78dbb9939ba002618bab919cb0536238deee6f3d3547af9776019c181afe28db4dfb51564834cc09d9107bf4a637d3b13966fb50669c
7
- data.tar.gz: 4b8496dde13c15551e497434d8976bce6711023010a2e81f6412b05baa4df4fea1f631189800d3e6f9bd7365ac77a1b6a6da9ad9a2470937b3d381989ee505ed
6
+ metadata.gz: be070361f7952a1b4bfd04b02a95f3a756cf66ed258a6462784ace866e0ded8ee7d53ced926f26a72fc7498884f37137931f8395416d9c66cfa41bf68f5079e5
7
+ data.tar.gz: a426868603e91dc578921ec8750912cc83cd8d6063477353a842c838a16c0276487d4ce8b001e2c9937969d77aab1a20f1ba29c183e015adf24e181d4d9d75ee
data/README.md CHANGED
@@ -28,6 +28,7 @@ gem install fluent-plugin-filter-kv-parser
28
28
  filtered_keys akey,bkey,ckey
29
29
  filtered_keys_regex /^sub_[a-zA-Z_0-9]+/
30
30
  filter_out_lines_without_keys false
31
+ keys_prefix prefix
31
32
  </filter>
32
33
 
33
34
  <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.7"
6
+ s.version = "0.0.9"
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"
@@ -15,6 +15,7 @@ module Fluent
15
15
  config_param :filtered_keys, :string, default: nil
16
16
  config_param :filtered_keys_regex, :string, default: nil
17
17
  config_param :filtered_keys_delimiter, :string, default: ','
18
+ config_param :keys_prefix, :string, default: nil
18
19
 
19
20
 
20
21
  def configure(conf)
@@ -57,7 +58,8 @@ module Fluent
57
58
  def extracted_keys(line)
58
59
  keys = @use_regex ? regex_filter(line) : delimiter_filter(line)
59
60
  filtered_keys = @filtered_keys_list.empty? ? keys : keys.slice(*@filtered_keys_list)
60
- @filtered_keys_regex.nil? ? filtered_keys : filtered_keys.merge(keys.select{ |k,v| @filtered_keys_regex.match(k.to_s)})
61
+ filtered_keys = @filtered_keys_regex.nil? ? filtered_keys : filtered_keys.merge(keys.select{ |k,v| @filtered_keys_regex.match(k.to_s)})
62
+ @keys_prefix.nil? ? filtered_keys : filtered_keys.transform_keys!{ |key| "#{@keys_prefix}.#{key}" }
61
63
  end
62
64
 
63
65
  def delimiter_filter(line)
@@ -212,4 +212,18 @@ class KeyValueFilterTest < Test::Unit::TestCase
212
212
  assert_equal 4, filtered.first[2].count
213
213
  assert_equal "10", filtered.first[2]['akey']
214
214
  end
215
+
216
+ test 'test_keys_prefix' do
217
+ d = create_driver(%[
218
+ key log
219
+ keys_prefix test
220
+ ])
221
+ msg = {
222
+ 'time' => '2013-02-12 22:01:15 UTC',
223
+ 'log' => 'Start Request key=10 akey=20 zkey=30 dkey=40',
224
+ }
225
+ filtered = filter(d, [msg]).first[2]
226
+ assert_equal false, filtered.key?("key")
227
+ assert_equal true, filtered.key?("test.key")
228
+ end
215
229
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Al-waleed Shihadeh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-11 00:00:00.000000000 Z
11
+ date: 2022-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.0.3
124
+ rubygems_version: 3.0.3.1
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: A Fluentd filter plugin to parse key value items