fluent-plugin-parse_request_body 0.0.7 → 0.0.8
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: 2fb78f2eddd80335a8193e11b18434aa4d4a74b93dbc6d5ee5d8ce7669cf361b
|
4
|
+
data.tar.gz: 897b0d888be39d0a7666583bc44de593c063827d2936642180bc27ca313861b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62fb9d3b2bf898ac49ec549a2f0ca3b83f510761baa3144bf43d07031e98cf73eaf3e12812fd909fab3be714b82fb2e68ee9b607083c3f2e05e8de1786240b79
|
7
|
+
data.tar.gz: 9c14657fe45a413ea91ca7291ff04f7bdbc2ed107ddeef8b80c97d626e6f531a3cc335632098538732c8984b9ae62619988b9999e16a346414f07838d939fde7
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'fluent-plugin-parse_request_body'
|
3
|
-
gem.version = '0.0.
|
3
|
+
gem.version = '0.0.8'
|
4
4
|
gem.authors = ['EkiSong']
|
5
5
|
gem.email = ['yifriday0614@gmail.com']
|
6
6
|
gem.homepage = 'https://github.com/yifriday/fluent-plugin-parse_request_body.git'
|
@@ -8,6 +8,10 @@ module Fluent::Plugin
|
|
8
8
|
|
9
9
|
desc "point a key whose value contains URL string."
|
10
10
|
config_param :key, :string
|
11
|
+
desc "If set, the key/value will be reformd array whose would be added to the record."
|
12
|
+
config_param :array_value, :string, default: nil
|
13
|
+
desc "array_value's key in record"
|
14
|
+
config_param :array_value_key, :string, default: nil
|
11
15
|
desc "If set, only the key/value whose key is included only will be added to the record."
|
12
16
|
config_param :only, :string, default: nil
|
13
17
|
desc "If set, the key/value whose key is included except will NOT be added to the record."
|
@@ -19,6 +23,7 @@ module Fluent::Plugin
|
|
19
23
|
desc "If set to true, permit blank key."
|
20
24
|
config_param :permit_blank_key, :bool, default: false
|
21
25
|
|
26
|
+
|
22
27
|
def configure(conf)
|
23
28
|
super
|
24
29
|
@extractor = Fluent::Plugin::ParseRequestBodyExtractor.new(self, conf)
|
@@ -11,6 +11,10 @@ module Fluent::Plugin
|
|
11
11
|
|
12
12
|
desc "point a key whose value contains URL string."
|
13
13
|
config_param :key, :string
|
14
|
+
desc "If set, the key/value will be reformd array whose would be added to the record."
|
15
|
+
config_param :array_value, :string, default: nil
|
16
|
+
desc "array_value's key in record"
|
17
|
+
config_param :array_value_key, :string, default: nil
|
14
18
|
desc "If set, only the key/value whose key is included only will be added to the record."
|
15
19
|
config_param :only, :string, default: nil
|
16
20
|
desc "If set, the key/value whose key is included except will NOT be added to the record."
|
@@ -22,6 +22,8 @@ module Fluent::Plugin
|
|
22
22
|
@discard_key = plugin.discard_key
|
23
23
|
@add_field_prefix = plugin.add_field_prefix
|
24
24
|
@permit_blank_key = plugin.permit_blank_key
|
25
|
+
@array_value = plugin.array_value
|
26
|
+
@array_value_key = plugin.array_value_key
|
25
27
|
|
26
28
|
if @only
|
27
29
|
@include_keys = @only.split(/\s*,\s*/).inject({}) do |hash, i|
|
@@ -37,22 +39,15 @@ module Fluent::Plugin
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
@
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
def add_record_field(record)
|
51
|
-
return record if @map.values.first.nil?
|
52
|
-
@map.each do |record_key, value|
|
53
|
-
record[record_key] = value
|
42
|
+
if @array_value_key
|
43
|
+
if @array_value
|
44
|
+
@include_array_value = @array_value.split(/\s*,\s*/).inject({}) do |hash, i|
|
45
|
+
hash[i] = true
|
46
|
+
hash
|
47
|
+
end
|
48
|
+
end
|
54
49
|
end
|
55
|
-
|
50
|
+
|
56
51
|
end
|
57
52
|
|
58
53
|
def add_query_params_field(record)
|
@@ -89,7 +84,7 @@ module Fluent::Plugin
|
|
89
84
|
|
90
85
|
def add_query_params(body, record)
|
91
86
|
return if body.nil?
|
92
|
-
|
87
|
+
placeholder = [];
|
93
88
|
body.split('&').each do |pair|
|
94
89
|
key, value = pair.split('=', 2).map { |i| CGI.unescape(i) }
|
95
90
|
next if (key.nil? || key.empty?) && (!permit_blank_key? || value.nil? || value.empty?)
|
@@ -104,7 +99,15 @@ module Fluent::Plugin
|
|
104
99
|
else
|
105
100
|
record[new_key] = value
|
106
101
|
end
|
102
|
+
if @include_array_value
|
103
|
+
placeholder[placeholder.size] = value if !@include_array_value.has_key?(key)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
unless placeholder.empty?
|
108
|
+
record[@array_value_key] = placeholder;
|
107
109
|
end
|
110
|
+
|
108
111
|
end
|
109
112
|
end
|
110
113
|
end
|