logstash-filter-remove_key_pattern 0.1.3 → 0.1.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
2
  SHA1:
3
- metadata.gz: 7d837bda20e4d81b49d49548f2a5a024611fd614
4
- data.tar.gz: 87d6392274e403878814b8f8717d01f091ba7f16
3
+ metadata.gz: eb505c544490f7cfe27056117ab2cc52418183c3
4
+ data.tar.gz: 633abf824180ef2ac092aaea04904b68102014be
5
5
  SHA512:
6
- metadata.gz: 2f51edc00e299f442ea9d61904abcab48bbdf98238a9688272e98af213bc2d8e99d5c8a0c75d7c046673fedd3a67da780e973da2a282c9d087418cb720c3b90d
7
- data.tar.gz: 66e45c6a24f40d13eb8d39142abf87da840fd1a71f51a660d7cd5d98ecc9940982e312892c5c637f8eb86826a6ff49f6f2b76fec0421e6b44dae3e819ec143f5
6
+ metadata.gz: 5830c0a33ab3fb4c5c2ee6d818941e8830b56287ce3538937c78c3540468a6cd0b5de292e301731a31192660686e2b5543935d2004a4ad61e7dfe9812f6a3e10
7
+ data.tar.gz: 4e0494af7a77ed84d3bbe0742677cc643267eb35829227303149e27e95c5415983e62db42a65029da490e061025284c6f1a56a9e21e6dd34a9316a80a6ec54e1
@@ -11,7 +11,7 @@ require "logstash/json"
11
11
  # [source, ruby]
12
12
  # filter {
13
13
  # remove_key_pattern {
14
- # parent_keys => ["haystack1", "haystack2"]
14
+ # parent_key => "haystack1"
15
15
  # pattern => ["\\d", "needle"]
16
16
  # keep_only_ids => "true"
17
17
  # }
@@ -22,7 +22,7 @@ class LogStash::Filters::RemoveKeyPattern < LogStash::Filters::Base
22
22
  config_name "remove_key_pattern"
23
23
 
24
24
  # Array of parent keys to remove from
25
- config :parent_keys, :validate => :array, :required => true
25
+ config :parent_key, :validate => :string, :required => true
26
26
 
27
27
  # Array of patterns to remove
28
28
  config :pattern, :validate => :array, :required => true
@@ -42,16 +42,14 @@ class LogStash::Filters::RemoveKeyPattern < LogStash::Filters::Base
42
42
 
43
43
  public
44
44
  def filter(event)
45
- @parent_keys.each do |key|
46
- remove_pattern(event, key) unless event.get(key).nil?
47
- end
45
+ remove_pattern(event) unless event.get(@parent_key).nil?
48
46
  filter_matched(event)
49
47
  end
50
48
 
51
49
  private
52
- def remove_pattern(event, key)
50
+ def remove_pattern(event)
53
51
  hash = {}
54
- event.get(key).each do |k, v|
52
+ event.get(@parent_key).each do |k, v|
55
53
  unless (k =~ @pattern)
56
54
  if @keep_only_ids && (k == 'id' or k =~ /.*_id$/)
57
55
  hash[k] = v
@@ -60,10 +58,6 @@ class LogStash::Filters::RemoveKeyPattern < LogStash::Filters::Base
60
58
  end
61
59
  end
62
60
  end
63
- begin
64
- event.set(key, hash)
65
- rescue LogStash::Json::GeneratorError
66
- return
67
- end
61
+ event.set(@parent_key, hash)
68
62
  end
69
63
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-remove_key_pattern'
3
- s.version = '0.1.3'
3
+ s.version = '0.1.4'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'Remove all keys that match pattern'
6
6
  s.authors = ['Arthur Alfredo']
@@ -8,7 +8,7 @@ describe LogStash::Filters::RemoveKeyPattern do
8
8
  config <<-CONFIG
9
9
  filter {
10
10
  remove_key_pattern {
11
- parent_keys => ["haystack2", "haystack"]
11
+ parent_key => "haystack2"
12
12
  pattern => ["needle", "\\d"]
13
13
  keep_only_ids => "true"
14
14
  }
@@ -37,10 +37,6 @@ describe LogStash::Filters::RemoveKeyPattern do
37
37
  }
38
38
 
39
39
  sample(hash) do
40
- insist { subject.get("hello") }.include?("numbers")
41
- insist { subject.get("haystack") }.include?("id")
42
- insist { subject.get("haystack") }.include?("key_four_id")
43
- reject { subject.get("haystack") }.include?("key4_id")
44
40
  reject { subject.get("haystack2") }.include?("needle")
45
41
  insist { subject.get("haystack2") }.include?("key_one_id")
46
42
  reject { subject.get("haystack2") }.include?("key4_id")
@@ -53,7 +49,7 @@ describe LogStash::Filters::RemoveKeyPattern do
53
49
  config <<-CONFIG
54
50
  filter {
55
51
  remove_key_pattern {
56
- parent_keys => ["haystack2", "haystack"]
52
+ parent_key => "haystack"
57
53
  pattern => ["needle", "\\d"]
58
54
  keep_only_ids => "false"
59
55
  }
@@ -82,15 +78,9 @@ describe LogStash::Filters::RemoveKeyPattern do
82
78
  }
83
79
 
84
80
  sample(hash) do
85
- insist { subject.get("hello") }.include?("numbers")
86
81
  insist { subject.get("haystack") }.include?("id")
87
82
  insist { subject.get("haystack") }.include?("key_four_id")
88
83
  reject { subject.get("haystack") }.include?("key4_id")
89
- reject { subject.get("haystack2") }.include?("needle")
90
- insist { subject.get("haystack2") }.include?("key_one_id")
91
- reject { subject.get("haystack2") }.include?("key4_id")
92
- insist { subject.get("haystack2") }.include?("key")
93
- insist { subject.get("haystack2") }.include?("foobar")
94
84
  end
95
85
  end
96
86
 
@@ -98,7 +88,7 @@ describe LogStash::Filters::RemoveKeyPattern do
98
88
  config <<-CONFIG
99
89
  filter {
100
90
  remove_key_pattern {
101
- parent_keys => ["h2", "h1"]
91
+ parent_key => "h2"
102
92
  pattern => ["needle", "\\d"]
103
93
  keep_only_ids => "true"
104
94
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-remove_key_pattern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Alfredo