fluent-plugin-parse_request_body 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb27080f5d4d14b0737d8bec5f175683388a9049b8f498c7f24908117a08b8f7
4
- data.tar.gz: 2c528cc8b3e0eb5e8ca9fe54ba2a2e6bb5b13b139d7fb16777217881d674c583
3
+ metadata.gz: 2fb78f2eddd80335a8193e11b18434aa4d4a74b93dbc6d5ee5d8ce7669cf361b
4
+ data.tar.gz: 897b0d888be39d0a7666583bc44de593c063827d2936642180bc27ca313861b8
5
5
  SHA512:
6
- metadata.gz: e024e036343faa226bd4be4ff2037552f0849b82ed9f7df5c7f7c4b2e0c9547b89ac4c55f6ccc961219f1cc9b13a32f42f16f5397fcda49bfb1c0bf49c9f0341
7
- data.tar.gz: dedab1341e47045f00eb8002ddc171412f3739d176a9acda27c5ee602940481a80fa093d878dd32d885b3baa7ff5f45ca6480924113b47a6253ea843a66442df
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.7'
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
- @map = {}
41
- # <record></record> directive
42
- conf.elements.select { |element| element.name == 'record' }.each { |element|
43
- element.each_pair { |k, v|
44
- element.has_key?(k) # to suppress unread configuration warning
45
- @map[k] = v
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
- record
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
- add_record_field(record)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-parse_request_body
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - EkiSong