fluent-plugin-filter-list 0.4.3 → 0.5.0

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: 61d9d3071404bc65e8aa1cb85c1375436f8fce088e54ed118e1b73698c0d73de
4
- data.tar.gz: ba810440dc189c6ea8a0cc94142dc8b5f87636756ee80e24c57d560fdad5af08
3
+ metadata.gz: 17bee9e79c216bfbdf746e8d7d089d229b2997bccf376d24c5e7311f1931f2b4
4
+ data.tar.gz: b00d3238b9a8d775f5f1dc2e7fd03beedde536bc6894d38f22091395d3dde1bf
5
5
  SHA512:
6
- metadata.gz: bbc45bdceb06bba6907dc229e139e72b5013bc20addd935f51f15e1975fa7e023f24a5edd4ead2ba1db0cee0adb87a16f25b456fcbbb97b3eaf8c5612cbbbc4c
7
- data.tar.gz: 88014dbb02b3afc0d485d7f7a0a628d9e0fe3c7a3a146001a95c7535c957a3aeecaa3f42ddcb065aa615f429e6cb70a5814d88f1c9d132879aaeca83da8ad5a2
6
+ metadata.gz: c578ea80823b2c26e70a37cf63b3df24832bef79013fcd7e1c28cbf937d220130581bd2a382a6ef06b5c9d1b96838a12d154b1263512920214041cfdfe467ee5
7
+ data.tar.gz: 513142ca73ebf949f94d3f22fea2deff6e5147ffea92d65687ce33c80c6217e9d70d47dc3ec53b47858a5edb725c1b43ba70334e0feece51971978ca9fe886f4
@@ -17,7 +17,7 @@ Style/FrozenStringLiteralComment:
17
17
  Style/MutableConstant:
18
18
  Enabled: false
19
19
  Metrics/AbcSize:
20
- Max: 25
20
+ Max: 30
21
21
  Metrics/BlockLength:
22
22
  Exclude:
23
23
  - 'Rakefile'
@@ -29,9 +29,9 @@ Metrics/BlockLength:
29
29
  - 'config/routes/**/*.rb'
30
30
  - '*.gemspec'
31
31
  Metrics/CyclomaticComplexity:
32
- Max: 10
32
+ Max: 15
33
33
  Metrics/PerceivedComplexity:
34
- Max: 10
34
+ Max: 15
35
35
  Style/GlobalVars:
36
36
  Exclude:
37
37
  - 'test/test_helper.rb'
data/README.md CHANGED
@@ -34,8 +34,9 @@ Use the `filter_list` filter. Configure fluentd as follows.
34
34
  @type filter_list
35
35
 
36
36
  filter AC
37
- key_to_filter xyz
37
+ key_to_filter x
38
38
  patterns_file_path blacklist.txt
39
+ filter_empty true
39
40
  </filter>
40
41
  ```
41
42
 
@@ -50,13 +51,28 @@ buzz
50
51
  The following message is discarded since its `x` field contains the sequence of characters _bar_, contained in the list.
51
52
 
52
53
  ```json
53
- {"x":"halbart","y":1}
54
+ {
55
+ "x": "halbart",
56
+ "y": 1
57
+ }
54
58
  ```
55
59
 
56
- While the following message is passed through as the target field specified in the config is not _y_ but _x_ .
60
+ While the following message is passed through as the target field specified in the config is not _y_ but _x_.
57
61
 
58
62
  ```json
59
- {"x":1,"y":"halbart"}
63
+ {
64
+ "x": 1,
65
+ "y": "halbart"
66
+ }
67
+ ```
68
+
69
+ Additionally, the following message is also omitted since `filter_empty` is `true`. The value is determined to be empty when the trimed value is empty.
70
+
71
+ ```json
72
+ {
73
+ "x": " ",
74
+ "y": "halbart"
75
+ }
60
76
  ```
61
77
 
62
78
  #### IPMatcher
@@ -81,19 +97,28 @@ Given the `blacklist.txt` is as follows.
81
97
  The following message is discarded since its `ip` field is the IP address in the list (exact IP).
82
98
 
83
99
  ```json
84
- {"ip":"255.255.0.0","y":1}
100
+ {
101
+ "ip": "255.255.0.0",
102
+ "y": 1
103
+ }
85
104
  ```
86
105
 
87
106
  Also the following message is discarded since its `ip` field is the IP address in the list (CIDR-notated IP).
88
107
 
89
108
  ```json
90
- {"ip":"192.168.1.255","y":1}
109
+ {
110
+ "ip": "192.168.1.255",
111
+ "y": 1
112
+ }
91
113
  ```
92
114
 
93
115
  While the following message is passed through.
94
116
 
95
117
  ```json
96
- {"ip":"192.168.2.0","y":1}
118
+ {
119
+ "ip": "192.168.2.0",
120
+ "y": 1
121
+ }
97
122
  ```
98
123
 
99
124
  ### Output plugin
@@ -106,6 +131,7 @@ The other use case is to filter messages likewise, but process the filtered mess
106
131
 
107
132
  key_to_filter field_name_you_want_to_filter
108
133
  patterns_file_path file_including_patterns_separated_by_new_line
134
+ filter_empty true
109
135
 
110
136
  <retag>
111
137
  add_prefix x # retag non-filtered messages whose tag will be "x.your_tag"
@@ -14,6 +14,7 @@ module Fluent
14
14
  config_param :filter, :string, default: 'AC'
15
15
  config_param :key_to_filter, :string, default: nil
16
16
  config_param :patterns_file_path, :string, default: ''
17
+ config_param :filter_empty, :bool, default: false
17
18
 
18
19
  def configure(conf)
19
20
  super
@@ -23,7 +24,7 @@ module Fluent
23
24
 
24
25
  def filter(_tag, _time, record)
25
26
  target = record[@key_to_filter]
26
- return nil if target && @matcher.matches?(target)
27
+ return nil if target && (@matcher.matches?(target) || (@filter_empty && target.strip.empty?))
27
28
  record
28
29
  end
29
30
  end
@@ -16,6 +16,7 @@ module Fluent
16
16
  config_param :filter, :string, default: 'AC'
17
17
  config_param :key_to_filter, :string, default: nil
18
18
  config_param :patterns_file_path, :string, default: ''
19
+ config_param :filter_empty, :bool, default: false
19
20
 
20
21
  config_section :retag, required: true, multi: false do
21
22
  config_param :tag, :string, default: nil
@@ -71,7 +72,7 @@ module Fluent
71
72
  target = record[@key_to_filter]
72
73
  log.debug "target: #{target}"
73
74
  # Do filter
74
- if target && @matcher.matches?(target)
75
+ if target && (@matcher.matches?(target) || (@filter_empty && target.strip.empty?))
75
76
  if @retag_for_filtered
76
77
  t = @retag_for_filtered.tag || ((tag && !tag.empty?) ? @prefix_for_filtered_tag + tag : @retag_for_filtered.add_prefix)
77
78
  log.debug "re-emit with the tag: '#{t}', originally: '#{tag}'"
@@ -1,7 +1,7 @@
1
1
  module Fluent
2
2
  module Plugin
3
3
  module FilterList
4
- VERSION = "0.4.3"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ module Matchers
12
12
 
13
13
  def matches?(text)
14
14
  node = @trie.root
15
- text.to_s.split('').each do |char|
15
+ text.to_s.chars.each do |char|
16
16
  node = node.failure while node.children[char].nil? # Follow failure if it exists in case pattern doesn't match
17
17
  node = node.children[char]
18
18
  return true unless node.output.nil?
@@ -50,7 +50,7 @@ module Matchers
50
50
 
51
51
  def insert(pattern = '')
52
52
  current_node = @root
53
- pattern.split('').each_with_index do |char, i|
53
+ pattern.chars.each_with_index do |char, i|
54
54
  current_node = current_node.insert(char)
55
55
  current_node.output = pattern if i == pattern.length - 1
56
56
  end
@@ -83,7 +83,7 @@ module Matchers
83
83
  def forward_match(pattern)
84
84
  return false if @root.children.empty?
85
85
  cur_node = @root
86
- pattern.split('').each do |char|
86
+ pattern.chars.each do |char|
87
87
  return true if cur_node.children.empty?
88
88
  return false unless cur_node.children.key?(char)
89
89
  cur_node = cur_node.children[char]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-filter-list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shun Yanaura