logstash-filter-kv 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/logstash/filters/kv.rb +18 -7
- data/logstash-filter-kv.gemspec +1 -1
- data/spec/filters/kv_spec.rb +16 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89fab778db6cbc596686f72f373c528ae84a92d5
|
4
|
+
data.tar.gz: 49a11f4d5b256a0ca5edc20d55708b5209065d8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4196694c4bd9ced68c2a538cce208c0cb72abcc1c301e4565f3b0253ebc3dc249daf5b109ea5a74a386688e2f4735430ca4748e921d63f09ee96546c9f5305ab
|
7
|
+
data.tar.gz: ec32f4fbd402c545f6a3d3177416eac8dbebd3e6768e41e4b9798af823a30fbae4393e474e1f81efcb975a91ca04c2ae9655b6fdb04c2e97d95e6a5cc3791bb4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 2.0.7
|
2
|
+
- With include_brackets enabled, angle brackets (\< and \>) are treated the same as square brackets and parentheses, making it easy to parse strings like "a=\<b\> c=\<d\>".
|
3
|
+
- An empty value_split option value now gives a useful error message.
|
4
|
+
|
1
5
|
# 2.0.6
|
2
6
|
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
3
7
|
# 2.0.5
|
data/lib/logstash/filters/kv.rb
CHANGED
@@ -87,7 +87,7 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
87
87
|
config :field_split, :validate => :string, :default => ' '
|
88
88
|
|
89
89
|
|
90
|
-
# A string of characters to use as delimiters for identifying key-value relations.
|
90
|
+
# A non-empty string of characters to use as delimiters for identifying key-value relations.
|
91
91
|
#
|
92
92
|
# These characters form a regex character class and thus you must escape special regex
|
93
93
|
# characters like `[` or `]` using `\`.
|
@@ -173,8 +173,8 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
173
173
|
# }
|
174
174
|
config :allow_duplicate_values, :validate => :boolean, :default => true
|
175
175
|
|
176
|
-
# A boolean specifying whether to
|
177
|
-
#
|
176
|
+
# A boolean specifying whether to treat square brackets, angle brackets,
|
177
|
+
# and parentheses as value "wrappers" that should be removed from the value.
|
178
178
|
# [source,ruby]
|
179
179
|
# filter {
|
180
180
|
# kv {
|
@@ -183,17 +183,19 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
183
183
|
# }
|
184
184
|
#
|
185
185
|
# For example, the result of this line:
|
186
|
-
# `bracketsone=(hello world) bracketstwo=[hello world]
|
186
|
+
# `bracketsone=(hello world) bracketstwo=[hello world] bracketsthree=<hello world>`
|
187
187
|
#
|
188
188
|
# will be:
|
189
189
|
#
|
190
190
|
# * bracketsone: hello world
|
191
191
|
# * bracketstwo: hello world
|
192
|
+
# * bracketsthree: hello world
|
192
193
|
#
|
193
194
|
# instead of:
|
194
195
|
#
|
195
196
|
# * bracketsone: (hello
|
196
197
|
# * bracketstwo: [hello
|
198
|
+
# * bracketsthree: <hello
|
197
199
|
#
|
198
200
|
config :include_brackets, :validate => :boolean, :default => true
|
199
201
|
|
@@ -212,11 +214,20 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
212
214
|
config :recursive, :validate => :boolean, :default => false
|
213
215
|
|
214
216
|
def register
|
217
|
+
if @value_split.empty?
|
218
|
+
raise LogStash::ConfigurationError, I18n.t(
|
219
|
+
"logstash.agent.configuration.invalid_plugin_register",
|
220
|
+
:plugin => "filter",
|
221
|
+
:type => "kv",
|
222
|
+
:error => "Configuration option 'value_split' must be a non-empty string"
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
215
226
|
@trim_re = Regexp.new("[#{@trim}]") if @trim
|
216
227
|
@trimkey_re = Regexp.new("[#{@trimkey}]") if @trimkey
|
217
228
|
|
218
229
|
valueRxString = "(?:\"([^\"]+)\"|'([^']+)'"
|
219
|
-
valueRxString += "|\\(([^\\)]+)\\)|\\[([^\\]]+)\\]" if @include_brackets
|
230
|
+
valueRxString += "|\\(([^\\)]+)\\)|\\[([^\\]]+)\\]|<([^>]+)>" if @include_brackets
|
220
231
|
valueRxString += "|((?:\\\\ |[^" + @field_split + "])+))"
|
221
232
|
@scan_re = Regexp.new("((?:\\\\ |[^" + @field_split + @value_split + "])+)\s*[" + @value_split + "]\s*" + valueRxString)
|
222
233
|
@value_split_re = /[#{@value_split}]/
|
@@ -266,8 +277,8 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
266
277
|
include_keys = @include_keys.map{|key| event.sprintf(key)}
|
267
278
|
exclude_keys = @exclude_keys.map{|key| event.sprintf(key)}
|
268
279
|
|
269
|
-
text.scan(@scan_re) do |key, v1, v2, v3, v4, v5|
|
270
|
-
value = v1 || v2 || v3 || v4 || v5
|
280
|
+
text.scan(@scan_re) do |key, v1, v2, v3, v4, v5, v6|
|
281
|
+
value = v1 || v2 || v3 || v4 || v5 || v6
|
271
282
|
key = @trimkey ? key.gsub(@trimkey_re, "") : key
|
272
283
|
|
273
284
|
# Bail out as per the values of include_keys and exclude_keys
|
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 = '2.0.
|
4
|
+
s.version = '2.0.7'
|
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"
|
data/spec/filters/kv_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe LogStash::Filters::KV do
|
|
14
14
|
}
|
15
15
|
CONFIG
|
16
16
|
|
17
|
-
sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world' bracketsone=(hello world) bracketstwo=[hello world]" do
|
17
|
+
sample "hello=world foo=bar baz=fizz doublequoted=\"hello world\" singlequoted='hello world' bracketsone=(hello world) bracketstwo=[hello world] bracketsthree=<hello world>" do
|
18
18
|
insist { subject["hello"] } == "world"
|
19
19
|
insist { subject["foo"] } == "bar"
|
20
20
|
insist { subject["baz"] } == "fizz"
|
@@ -22,6 +22,7 @@ describe LogStash::Filters::KV do
|
|
22
22
|
insist { subject["singlequoted"] } == "hello world"
|
23
23
|
insist { subject["bracketsone"] } == "hello world"
|
24
24
|
insist { subject["bracketstwo"] } == "hello world"
|
25
|
+
insist { subject["bracketsthree"] } == "hello world"
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -629,4 +630,18 @@ describe LogStash::Filters::KV do
|
|
629
630
|
end
|
630
631
|
end
|
631
632
|
end
|
633
|
+
|
634
|
+
describe "an empty value_split option should be reported" do
|
635
|
+
config <<-CONFIG
|
636
|
+
filter {
|
637
|
+
kv {
|
638
|
+
value_split => ""
|
639
|
+
}
|
640
|
+
}
|
641
|
+
CONFIG
|
642
|
+
|
643
|
+
sample("message" => "random message") do
|
644
|
+
insist { subject }.raises(LogStash::ConfigurationError)
|
645
|
+
end
|
646
|
+
end
|
632
647
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-kv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- -
|
16
|
+
- - ~>
|
17
17
|
- !ruby/object:Gem::Version
|
18
18
|
version: '1.0'
|
19
19
|
name: logstash-core-plugin-api
|
@@ -21,13 +21,13 @@ dependencies:
|
|
21
21
|
type: :runtime
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0'
|
33
33
|
name: logstash-devutils
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
type: :development
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
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
|
@@ -65,17 +65,17 @@ require_paths:
|
|
65
65
|
- lib
|
66
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - '>='
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.4.
|
78
|
+
rubygems_version: 2.4.5
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: This filter helps automatically parse messages (or specific event fields) which are of the 'foo=bar' variety.
|