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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8932148ec7a3bfaa0a6241823bda594b85d5a91b24dca0156fb2e7497e4f5eef
|
4
|
+
data.tar.gz: 810626b5c05a84a382719b9bb40393ee3f901b7d3d9b8366114e1b8633e08621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89089861029085470ada61bb7d34bee99d33c46b3d089b56fc840c4f2881a479fab0a31a0f6ea663171d1c3bb5e7eface8cd5e92cd0c57b4769179e55c6ba610
|
7
|
+
data.tar.gz: 8bba97ee414b53f06222af5f6f8bad5ef89e4e2538896a8f9e0a3b5c239ef594f796a7da033843cac4e62f1207eb38591a42827147757c6adfc38f9fdb8cf3b4
|
data/README.md
CHANGED
@@ -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.
|
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
|
-
|
43
|
+
keys = extracted_keys(extract_log_line(record[@key]))
|
43
44
|
|
44
|
-
|
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
|