logstash-filter-kv 4.5.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/index.asciidoc +12 -0
- data/lib/logstash/filters/kv.rb +14 -8
- data/logstash-filter-kv.gemspec +1 -1
- data/spec/filters/kv_spec.rb +21 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2127186e4a039aaadb013f982c1ed9815827b4c629979a9572a2000a961f3fb1
|
4
|
+
data.tar.gz: e79ab76e7787bb89b4aa0e901a78bc0412c3e9344ff6ac7ac23554b56f8f526b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 237975f6ce46e4d5e5ac94742ea4b7adc323691d22a670ea37d9ff68f111523ca0f5b6dd3f81bf8c5dd60a60b6dafd11d579e5c4fcfc383c356a43b72f8e277d
|
7
|
+
data.tar.gz: bc354d05d413b8781e0baf3076521cd6257baaa49a84650b3182fd076aa91b962558d247d9a8b55ee8485427ccc74e33e0505f97ca38b784b8b3c00333ea926b
|
data/CHANGELOG.md
CHANGED
data/docs/index.asciidoc
CHANGED
@@ -60,6 +60,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
60
60
|
|=======================================================================
|
61
61
|
|Setting |Input type|Required
|
62
62
|
| <<plugins-{type}s-{plugin}-allow_duplicate_values>> |<<boolean,boolean>>|No
|
63
|
+
| <<plugins-{type}s-{plugin}-allow_empty_values>> |<<boolean,boolean>>|No
|
63
64
|
| <<plugins-{type}s-{plugin}-default_keys>> |<<hash,hash>>|No
|
64
65
|
| <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
|
65
66
|
| <<plugins-{type}s-{plugin}-exclude_keys>> |<<array,array>>|No
|
@@ -109,6 +110,17 @@ you could use this configuration:
|
|
109
110
|
}
|
110
111
|
}
|
111
112
|
|
113
|
+
[id="plugins-{type}s-{plugin}-allow_empty_values"]
|
114
|
+
===== `allow_empty_values`
|
115
|
+
|
116
|
+
* Value type is <<boolean,boolean>>
|
117
|
+
* Default value is `false`
|
118
|
+
|
119
|
+
A bool option for explicitly including empty values.
|
120
|
+
When set to true, empty values will be added to the event.
|
121
|
+
|
122
|
+
NOTE: Parsing empty values typically requires <<plugins-{type}s-{plugin}-whitespace,`whitespace => strict`>>.
|
123
|
+
|
112
124
|
[id="plugins-{type}s-{plugin}-default_keys"]
|
113
125
|
===== `default_keys`
|
114
126
|
|
data/lib/logstash/filters/kv.rb
CHANGED
@@ -272,6 +272,9 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
272
272
|
# }
|
273
273
|
config :allow_duplicate_values, :validate => :boolean, :default => true
|
274
274
|
|
275
|
+
# A bool option for keeping empty or nil values.
|
276
|
+
config :allow_empty_values, :validate => :boolean, :default => false
|
277
|
+
|
275
278
|
# A boolean specifying whether to treat square brackets, angle brackets,
|
276
279
|
# and parentheses as value "wrappers" that should be removed from the value.
|
277
280
|
# [source,ruby]
|
@@ -337,6 +340,9 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
337
340
|
# Tag to apply if kv errors
|
338
341
|
config :tag_on_failure, :validate => :string, :default => '_kv_filter_error'
|
339
342
|
|
343
|
+
|
344
|
+
EMPTY_STRING = ''.freeze
|
345
|
+
|
340
346
|
def register
|
341
347
|
# Too late to set the regexp interruptible flag, at least warn if it is not set.
|
342
348
|
require 'java'
|
@@ -569,12 +575,12 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
569
575
|
exclude_keys = @exclude_keys.map{|key| event.sprintf(key)}
|
570
576
|
|
571
577
|
text.scan(@scan_re) do |key, *value_candidates|
|
572
|
-
value = value_candidates.compact.first
|
573
|
-
next if value.
|
578
|
+
value = value_candidates.compact.first || EMPTY_STRING
|
579
|
+
next if value.empty? && !@allow_empty_values
|
574
580
|
|
575
|
-
key =
|
576
|
-
key =
|
577
|
-
key =
|
581
|
+
key = key.gsub(@trim_key_re, EMPTY_STRING) if @trim_key
|
582
|
+
key = key.gsub(@remove_char_key_re, EMPTY_STRING) if @remove_char_key
|
583
|
+
key = transform(key, @transform_key) if @transform_key
|
578
584
|
|
579
585
|
# Bail out as per the values of include_keys and exclude_keys
|
580
586
|
next if not include_keys.empty? and not include_keys.include?(key)
|
@@ -583,9 +589,9 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
583
589
|
|
584
590
|
key = event.sprintf(@prefix) + key
|
585
591
|
|
586
|
-
value =
|
587
|
-
value =
|
588
|
-
value =
|
592
|
+
value = value.gsub(@trim_value_re, EMPTY_STRING) if @trim_value
|
593
|
+
value = value.gsub(@remove_char_value_re, EMPTY_STRING) if @remove_char_value
|
594
|
+
value = transform(value, @transform_value) if @transform_value
|
589
595
|
|
590
596
|
# Bail out if inserting duplicate value in key mapping when unique_values
|
591
597
|
# option is set to true.
|
data/logstash-filter-kv.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-kv'
|
4
|
-
s.version = '4.
|
4
|
+
s.version = '4.6.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Parses key-value pairs"
|
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/logstash-plugin install gemname. This gem is not a stand-alone program"
|
data/spec/filters/kv_spec.rb
CHANGED
@@ -721,6 +721,27 @@ describe LogStash::Filters::KV do
|
|
721
721
|
end
|
722
722
|
end
|
723
723
|
|
724
|
+
describe "Allowing empty values" do
|
725
|
+
config <<-CONFIG
|
726
|
+
filter {
|
727
|
+
kv {
|
728
|
+
field_split => " "
|
729
|
+
source => "source"
|
730
|
+
allow_empty_values => true
|
731
|
+
whitespace => strict
|
732
|
+
}
|
733
|
+
}
|
734
|
+
CONFIG
|
735
|
+
|
736
|
+
sample("source" => "present=one empty= emptyquoted='' present=two emptybracketed=[] endofinput=") do
|
737
|
+
insist { subject.get('[present]') } == ['one','two']
|
738
|
+
insist { subject.get('[empty]') } == ''
|
739
|
+
insist { subject.get('[emptyquoted]') } == ''
|
740
|
+
insist { subject.get('[emptybracketed]') } == ''
|
741
|
+
insist { subject.get('[endofinput]') } == ''
|
742
|
+
end
|
743
|
+
end
|
744
|
+
|
724
745
|
describe "Allow duplicate key/value pairs by default" do
|
725
746
|
config <<-CONFIG
|
726
747
|
filter {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-kv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -20,8 +20,8 @@ dependencies:
|
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '2.99'
|
22
22
|
name: logstash-core-plugin-api
|
23
|
-
type: :runtime
|
24
23
|
prerelease: false
|
24
|
+
type: :runtime
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
@@ -37,8 +37,8 @@ dependencies:
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '1.3'
|
39
39
|
name: logstash-mixin-ecs_compatibility_support
|
40
|
-
type: :runtime
|
41
40
|
prerelease: false
|
41
|
+
type: :runtime
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
@@ -51,8 +51,8 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '1.0'
|
53
53
|
name: logstash-mixin-validator_support
|
54
|
-
type: :runtime
|
55
54
|
prerelease: false
|
55
|
+
type: :runtime
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
@@ -65,8 +65,8 @@ dependencies:
|
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '0'
|
67
67
|
name: logstash-devutils
|
68
|
-
type: :development
|
69
68
|
prerelease: false
|
69
|
+
type: :development
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
@@ -79,8 +79,8 @@ dependencies:
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
name: insist
|
82
|
-
type: :development
|
83
82
|
prerelease: false
|
83
|
+
type: :development
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.1.6
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Parses key-value pairs
|