logstash-filter-kv 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: a2f193234be65735a775b9c6f760fdb39b0e147e
4
- data.tar.gz: 51155886466309a0c92d42778617e8f038efb4bb
3
+ metadata.gz: 5a4015b34b2918460e579fb2bae5e8a9bcc61420
4
+ data.tar.gz: 97bb73a8e6f988a384753a69ade43fc13b390fc7
5
5
  SHA512:
6
- metadata.gz: 30c7992eb2dcd323d6fbfa26de7f92a7615c0db51200870295d9b5279b4829d760a6343b292898009175e2c95f0dfb671050b6756406f25593cec12a80e66993
7
- data.tar.gz: c6abe01f5f9d4bf460b42752f11b8c71aa4e11162ffba5190919686efa41fbcca11bfdf4413c6f8841f5b71b4ea2cdf2f4fe8dbbf1f6d21da2352c8821c5df21
6
+ metadata.gz: 881f352227e3d6bc86812f8d04152761f45f4ecbba7b2e9829b01db87b2f97791b2204c7fdab06e5d41aab006d38f8d3fbb72cfc50b5f26a39a7ce91c8fae07f
7
+ data.tar.gz: 2824c28b60c78ca4cda3eee1514d0804edc1f1544cf4e87522ae32320a37c4cfe923c0dc0c4a6ca964f8f72e21fd3b6652329fc613d4742361d8de22f65c6614
@@ -158,6 +158,20 @@ class LogStash::Filters::KV < LogStash::Filters::Base
158
158
  # }
159
159
  config :default_keys, :validate => :hash, :default => {}
160
160
 
161
+ # A bool option for removing duplicate key/value pairs. When set to false, only
162
+ # one unique key/value pair will be preserved.
163
+ #
164
+ # For example, consider a source like `from=me from=me`. `[from]` will map to
165
+ # an Array with two elements: `["me", "me"]`. to only keep unique key/value pairs,
166
+ # you could use this configuration:
167
+ # [source,ruby]
168
+ # filter {
169
+ # kv {
170
+ # allow_duplicate_values => false
171
+ # }
172
+ # }
173
+ config :allow_duplicate_values, :validate => :boolean, :default => true
174
+
161
175
  def register
162
176
  @trim_re = Regexp.new("[#{@trim}]") if !@trim.nil?
163
177
  @trimkey_re = Regexp.new("[#{@trimkey}]") if !@trimkey.nil?
@@ -223,6 +237,11 @@ class LogStash::Filters::KV < LogStash::Filters::Base
223
237
  key = event.sprintf(@prefix) + key
224
238
 
225
239
  value = @trim.nil? ? value : value.gsub(@trim_re, "")
240
+
241
+ # Bail out if inserting duplicate value in key mapping when unique_values
242
+ # option is set to true.
243
+ next if not @allow_duplicate_values and kv_keys.has_key?(key) and kv_keys[key].include?(value)
244
+
226
245
  if kv_keys.has_key?(key)
227
246
  if kv_keys[key].is_a? Array
228
247
  kv_keys[key].push(value)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-kv'
4
- s.version = '0.1.3'
4
+ s.version = '0.1.4'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This filter helps automatically parse messages (or specific event fields) which are of the 'foo=bar' variety."
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -433,4 +433,34 @@ describe LogStash::Filters::KV do
433
433
 
434
434
  end
435
435
 
436
+ describe "Removing duplicate key/value pairs" do
437
+ config <<-CONFIG
438
+ filter {
439
+ kv {
440
+ field_split => "&"
441
+ source => "source"
442
+ allow_duplicate_values => false
443
+ }
444
+ }
445
+ CONFIG
446
+
447
+ sample("source" => "foo=bar&foo=yeah&foo=yeah") do
448
+ insist { subject["[foo]"] } == ["bar", "yeah"]
449
+ end
450
+ end
451
+
452
+ describe "Allow duplicate key/value pairs by default" do
453
+ config <<-CONFIG
454
+ filter {
455
+ kv {
456
+ field_split => "&"
457
+ source => "source"
458
+ }
459
+ }
460
+ CONFIG
461
+
462
+ sample("source" => "foo=bar&foo=yeah&foo=yeah") do
463
+ insist { subject["[foo]"] } == ["bar", "yeah", "yeah"]
464
+ end
465
+ end
436
466
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-kv
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
  - Elasticsearch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-27 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
14
+ name: logstash
15
+ version_requirements: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - '>='
17
18
  - !ruby/object:Gem::Version
@@ -19,10 +20,7 @@ dependencies:
19
20
  - - <
20
21
  - !ruby/object:Gem::Version
21
22
  version: 2.0.0
22
- name: logstash
23
- prerelease: false
24
- type: :runtime
25
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - '>='
28
26
  - !ruby/object:Gem::Version
@@ -30,20 +28,22 @@ dependencies:
30
28
  - - <
31
29
  - !ruby/object:Gem::Version
32
30
  version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
- requirement: !ruby/object:Gem::Requirement
34
+ name: logstash-devutils
35
+ version_requirements: !ruby/object:Gem::Requirement
35
36
  requirements:
36
37
  - - '>='
37
38
  - !ruby/object:Gem::Version
38
39
  version: '0'
39
- name: logstash-devutils
40
- prerelease: false
41
- type: :development
42
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: !ruby/object:Gem::Requirement
43
41
  requirements:
44
42
  - - '>='
45
43
  - !ruby/object:Gem::Version
46
44
  version: '0'
45
+ prerelease: false
46
+ type: :development
47
47
  description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
48
48
  email: info@elasticsearch.com
49
49
  executables: []