fluent-plugin-filter_empty_keys 0.0.3 → 0.0.4

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
- SHA1:
3
- metadata.gz: 8f90d886f79fd03b913bba8151528489e376380c
4
- data.tar.gz: b9e146a6345f7d985ef0003edf71a758cf396d05
2
+ SHA256:
3
+ metadata.gz: 8d9c1e349c66044733fba36cee0f128b368c335045ff619a29cc1550fccceabf
4
+ data.tar.gz: 9b005343fa79f152c1c8da7187f6b0e9285feaffeb50fb6e3632f635575ea590
5
5
  SHA512:
6
- metadata.gz: d1979232f4de1292104871165ca37889d5b3f6778c2a16da501da6615c5f1015f3fe614414be61aff48045ed2993acaa61bef5b889166700a5c901c1e4468f5e
7
- data.tar.gz: f693eb2bba9f3faa8d6418dd6470ff8a749eb83f4f7cd809c752ee82bf615893ec4819ca543c2367c5b372271b51d808741df0ece6d10d42d1aad1d31f116072
6
+ metadata.gz: f25ed059007a427c9582b90e92b134aabc1f080243c54d512b6a338bf29af9269bb367389f8079bc5a784c580f33a19ac1f397964f6c82fa6ee18d660f8926e8
7
+ data.tar.gz: 0f10f8300503bd1cdb834ad975c589230c8f7cd3e7556c489fc928aab8a5952512072993fc28bd0894a7fcad7a07f410d80758fb8542ad8af00f8329ab8e276e
data/CHANGELOG.md CHANGED
@@ -1,7 +1,14 @@
1
+ # 0.0.4
2
+ Enhancements:
3
+
4
+ * Support custom empty values.
5
+ * updated examples with `@type` instead deprecated `type`
6
+
7
+
1
8
  # 0.0.3
2
9
  Enhancements:
3
10
 
4
- * Support custome keys empty values.
11
+ * Support custom keys empty values.
5
12
 
6
13
  # 0.0.1
7
14
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # fluent-plugin-filter_typecast
1
+ # fluent-plugin-filter_empty_keys
2
2
 
3
3
  A Fluentd filter plugin to filter empty keys
4
4
 
@@ -18,45 +18,68 @@ gem install fluent-plugin-filter_empty_keys
18
18
 
19
19
  ```
20
20
  <source>
21
- type dummy
21
+ @type dummy
22
22
  tag dummy
23
- dummy {"field1":"","field2":"2","field3":"2013-02-12 22:04:14 UTC","field4":"","field5":"a,b,c"}
23
+ dummy {"field1":"", "field2":"2", "field3":"2013-02-12 22:04:14 UTC", "field4":"", "field5":"a,b,c"}
24
24
  </source>
25
25
 
26
26
  <filter **>
27
- type empty_keys
27
+ @type empty_keys
28
28
  </filter>
29
29
 
30
30
  <match **>
31
- type stdout
31
+ @type stdout
32
32
  </match>
33
33
  ```
34
34
 
35
35
  You should see casted records:
36
36
  ```
37
- dummy {"field2":"2","field3":"2013-02-12 22:04:14 UTC","field5":"a,b,c"}
37
+ dummy {"field2":"2", "field3":"2013-02-12 22:04:14 UTC", "field5":"a,b,c"}
38
38
  ```
39
39
 
40
40
  ```
41
41
  <source>
42
- type dummy
42
+ @type dummy
43
43
  tag dummy
44
- dummy {"field0":0,"field1":"","field2":"Undefined","field3":"2013-02-12 22:04:14 UTC","field4":"","field5":"a,b,c"}
44
+ dummy {"field0":0, "field1":"", "field2":"Undefined", "field3":"2013-02-12 22:04:14 UTC", "field4":"", "field5":"a,b,c"}
45
45
  </source>
46
46
 
47
47
  <filter **>
48
- type empty_keys
48
+ @type empty_keys
49
49
  empty_keys field0:0,field2:Undefined
50
50
  </filter>
51
51
 
52
52
  <match **>
53
- type stdout
53
+ @type stdout
54
54
  </match>
55
55
  ```
56
56
 
57
57
  You should see casted records:
58
58
  ```
59
- dummy {"field3":"2013-02-12 22:04:14 UTC","field5":"a,b,c"}
59
+ dummy {"field3":"2013-02-12 22:04:14 UTC", "field5":"a,b,c"}
60
+ ```
61
+
62
+ ```
63
+ <source>
64
+ @type dummy
65
+ tag dummy
66
+ dummy {"field0":0, "field1":"", "field2":"Undefined", "field3":"2013-02-12 22:04:14 UTC", "field4":"", "field5":"-"}
67
+ </source>
68
+
69
+ <filter **>
70
+ @type empty_keys
71
+ empty_values -,0
72
+ empty_values_delimiter ,
73
+ </filter>
74
+
75
+ <match **>
76
+ @type stdout
77
+ </match>
78
+ ```
79
+
80
+ You should see casted records:
81
+ ```
82
+ dummy {"field2":"Undefined","field3":"2013-02-12 22:04:14 UTC"}
60
83
  ```
61
84
 
62
85
  ## ChangeLog
data/example.conf CHANGED
@@ -1,7 +1,7 @@
1
1
  <filter **>
2
- type empty_keys
2
+ @type empty_keys
3
3
  </filter>
4
4
 
5
5
  <match **>
6
- type stdout
6
+ @type stdout
7
7
  </match>
@@ -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_empty_keys"
6
- s.version = "0.0.3"
6
+ s.version = "0.0.4"
7
7
  s.authors = ["Al-waleed Shihadeh"]
8
8
  s.email = ["wshihadh@gmail.com"]
9
9
  s.homepage = "https://github.com/wshihadeh/fluent-plugin-filter_empty_keys.git"
@@ -5,33 +5,52 @@ module Fluent
5
5
  class EmptyKeysFilter < Filter
6
6
  Fluent::Plugin.register_filter('empty_keys', self)
7
7
 
8
+ config_param :empty_values, :string, default: nil
8
9
  config_param :empty_keys, :string, default: nil
9
- config_param :keys_delimiter, :string, default: ','
10
- config_param :values_delimiter, :string, default: ':'
10
+ config_param :empty_keys_delimiter, :string, default: ','
11
+ config_param :empty_values_delimiter, :string, default: ','
12
+ config_param :empty_keys_value_delimiter, :string, default: ':'
11
13
 
12
14
  def configure(conf)
13
- super
14
-
15
- @keys_empty_values = nil
16
- @keys_empty_values = parse_empty_values_parameter unless @empty_keys.nil?
15
+ super
16
+ @all_empty_values = parse_empty_values_parameter
17
+ @keys_empty_values = nil
18
+ @keys_empty_values = parse_empty_keys_parameter unless @empty_keys.nil?
17
19
  end
18
20
 
19
- def filter(tag, time, record)
20
- record.reject{ |k,v| (v.nil? || v.to_s.empty? || (!@keys_empty_values.nil? && v.to_s.eql?(@keys_empty_values[k]))) }
21
+ def filter(_tag, _time, record)
22
+ record.reject do |k, v|
23
+ (
24
+ v.nil? ||
25
+ v.to_s.empty? ||
26
+ @all_empty_values.include?(v.to_s) ||
27
+ (!@keys_empty_values.nil? && v.to_s.eql?(@keys_empty_values[k]))
28
+ )
29
+ end
21
30
  end
22
31
 
23
32
  private
24
33
 
25
- def parse_empty_values_parameter
34
+ def parse_empty_keys_parameter
26
35
  keys_empty_values = {}
27
36
 
28
- @empty_keys.split(@keys_delimiter).each do |pattern_name|
29
- key, empty_value, format = pattern_name.split(@values_delimiter, 3)
30
- raise ConfigError, "EmptyValue is needed" if empty_value.nil?
37
+ @empty_keys.split(@empty_keys_delimiter).each do |pattern_name|
38
+ key, empty_value, _format = pattern_name.split(@empty_keys_value_delimiter, 3)
39
+ raise ConfigError, 'EmptyValue is needed' if empty_value.nil?
40
+
31
41
  keys_empty_values[key] = empty_value
32
42
  end
33
43
 
34
44
  keys_empty_values
35
45
  end
46
+
47
+ def parse_empty_values_parameter
48
+ if @empty_values.nil?
49
+ []
50
+ else
51
+ @empty_values.split(@empty_values_delimiter)
52
+ end
53
+ end
54
+
36
55
  end
37
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-filter_empty_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Al-waleed Shihadeh
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -104,7 +104,7 @@ homepage: https://github.com/wshihadeh/fluent-plugin-filter_empty_keys.git
104
104
  licenses:
105
105
  - MIT
106
106
  metadata: {}
107
- post_install_message:
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -119,9 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.6.14
124
- signing_key:
122
+ rubygems_version: 3.1.6
123
+ signing_key:
125
124
  specification_version: 4
126
125
  summary: A Fluentd filter plugin to filter empty keys
127
126
  test_files: