fluent-plugin-parse_request_body 0.0.22 → 0.0.23

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: d4c0e4b9d85b59d96171fd33c81a29d679169033675fbd2be71815349c96070b
4
- data.tar.gz: 027ad6295d9a75ee4c3060bf3fa51c3b84ba28a57556cb12fc8aa1a664a19fbe
3
+ metadata.gz: 98f8ceed9a0b3569b27010a747fb9c05f2c235538df3cbbca95cf30ea81cf1eb
4
+ data.tar.gz: ed1e96969458936b4e9fda28163114e041cbee3ec98275b9879e0c721a86a0f7
5
5
  SHA512:
6
- metadata.gz: 2a41dd258ad9828ecf957adbb5bf62ef85f7a0af46e21ce2fe5af8b1c9e578dfdee5f3502c1d7e6ecfc4c794440e9285f2e0dda0b8ef33751cabc7d676b9a68a
7
- data.tar.gz: 8beaf33aec39d512f0df6d7acf1966be7f60b11485cf407306e7fb79546d44ecbe56dcb5507635ef4f5ce54d59d8950dab065dc71c98571bd337c1f5de1f192c
6
+ metadata.gz: fdb3b41404baaac32ec32d2d6d8ff16d75e0eca73c5acfc02e6053cd2acf43a931d82d6d3c71dfd26c861641627658e30febae2aed5fcabc297c55e2b80234e5
7
+ data.tar.gz: ad45fdc9f323f24d8b5b953f80ec9bf72287076fb50e99b4cbb497097ccc52f2dbd80e5f7e8a6868b404a4f7c10168684fe8b7967a6848838f93d9bbce6cc231
@@ -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.22'
3
+ gem.version = '0.0.23'
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'
@@ -4,33 +4,44 @@ require "fluent/plugin/parse_request_body_extractor"
4
4
  module Fluent::Plugin
5
5
  class ParseRequestBodyFilter < Fluent::Plugin::Filter
6
6
 
7
+ #注册filter名称#
7
8
  Fluent::Plugin.register_filter('parse_request_body', self)
8
9
 
10
+ #request body在record中所对应的key#
9
11
  desc "point a key whose value contains body string."
10
12
  config_param :key, :string
13
+ #需要使用array_value替换数据的key#
11
14
  desc "point a key who will be replaced."
12
15
  config_param :replace_key, :string, default: nil
16
+ #需要被组合在一起的数据名称#
13
17
  desc "If set, the key/value will be reformd array whose would be added to the record."
14
18
  config_param :array_value, :string, default: nil
19
+ #最终组合数据在record中的key#
15
20
  desc "array_value's key in record"
16
21
  config_param :array_value_key, :string, default: nil
22
+ #request body解析数据白名单#
17
23
  desc "If set, only the key/value whose key is included only will be added to the record."
18
24
  config_param :only, :string, default: nil
25
+ #request body解析数据黑名单#
19
26
  desc "If set, the key/value whose key is included except will NOT be added to the record."
20
27
  config_param :except, :string, default: nil
28
+ #是否只保留最终解析出来的数据,而删除request body原数据#
21
29
  desc "If set to true, the original key url will be discarded from the record."
22
30
  config_param :discard_key, :bool, default: false
31
+ #给解析出的数据key添加前缀#
23
32
  desc "Prefix of fields."
24
33
  config_param :add_field_prefix, :string, default: nil
34
+ #是否允许解析空key#
25
35
  desc "If set to true, permit blank key."
26
36
  config_param :permit_blank_key, :bool, default: false
27
37
 
28
-
38
+ #初始化解析器#
29
39
  def configure(conf)
30
40
  super
31
41
  @extractor = Fluent::Plugin::ParseRequestBodyExtractor.new(self, conf)
32
42
  end
33
43
 
44
+ #执行解析工作#
34
45
  def filter(tag, time, record)
35
46
  @extractor.add_query_params_field(record)
36
47
  end
@@ -5,29 +5,40 @@ module Fluent::Plugin
5
5
  class ParseRequestBodyOutput < Fluent::Plugin::Output
6
6
  include Fluent::HandleTagNameMixin
7
7
 
8
+ #注册output名称#
8
9
  Fluent::Plugin.register_output('parse_request_body', self)
9
10
 
10
11
  helpers :event_emitter
11
12
 
13
+ #request body在record中所对应的key#
12
14
  desc "point a key whose value contains body string."
13
15
  config_param :key, :string
16
+ #需要使用array_value替换数据的key#
14
17
  desc "point a key who will be replaced."
15
18
  config_param :replace_key, :string, default: nil
19
+ #需要被组合在一起的数据名称#
16
20
  desc "If set, the key/value will be reformd array whose would be added to the record."
17
21
  config_param :array_value, :string, default: nil
22
+ #最终组合数据在record中的key#
18
23
  desc "array_value's key in record"
19
24
  config_param :array_value_key, :string, default: nil
25
+ #request body解析数据白名单#
20
26
  desc "If set, only the key/value whose key is included only will be added to the record."
21
27
  config_param :only, :string, default: nil
28
+ #request body解析数据黑名单#
22
29
  desc "If set, the key/value whose key is included except will NOT be added to the record."
23
30
  config_param :except, :string, default: nil
31
+ #是否只保留最终解析出来的数据,而删除request body原数据#
24
32
  desc "If set to true, the original key url will be discarded from the record."
25
33
  config_param :discard_key, :bool, default: false
34
+ #给解析出的数据key添加前缀#
26
35
  desc "Prefix of fields."
27
36
  config_param :add_field_prefix, :string, default: nil
37
+ #是否允许解析空key#
28
38
  desc "If set to true, permit blank key."
29
39
  config_param :permit_blank_key, :bool, default: false
30
40
 
41
+ #初始化解析器#
31
42
  def configure(conf)
32
43
  super
33
44
  @extractor = Fluent::Plugin::ParseRequestBodyExtractor.new(self, conf)
@@ -37,6 +48,7 @@ module Fluent::Plugin
37
48
  true
38
49
  end
39
50
 
51
+ #执行解析工作#
40
52
  def filter_record(tag, time, record)
41
53
  record = @extractor.add_query_params_field(record)
42
54
  super(tag, time, record)
@@ -104,7 +104,7 @@ module Fluent::Plugin
104
104
 
105
105
  def add_query_params(body, record)
106
106
  return if body.nil?
107
- placeholder = []
107
+ keyCcount = 0
108
108
  body.split('&').each do |pair|
109
109
  key, value = pair.split('=', 2).map { |i| CGI.unescape(i) }
110
110
  next if (key.nil? || key.empty?) && (!permit_blank_key? || value.nil? || value.empty?)
@@ -121,12 +121,13 @@ module Fluent::Plugin
121
121
  end
122
122
 
123
123
  if @include_array_value && @include_array_value.has_key?(key) && (value.to_f != 0)
124
- placeholder[placeholder.size] = value.to_f
124
+ @include_array_value.key(key) = value.to_f
125
+ keyCcount += 1
125
126
  end
126
127
  end
127
128
 
128
- unless placeholder.empty?
129
- record[@array_value_key] = placeholder
129
+ if @include_array_value.length == keyCcount
130
+ record[@array_value_key] = @include_array_value.value
130
131
  end
131
132
  end
132
133
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - EkiSong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-19 00:00:00.000000000 Z
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake