logstash-filter-split 3.0.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -2
- data/lib/logstash/filters/split.rb +35 -3
- data/logstash-filter-split.gemspec +2 -2
- data/spec/filters/split_spec.rb +15 -4
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c289e206791d9973f7c598e12d78142a7dae422
|
4
|
+
data.tar.gz: 8cbde317a3f26193de7a38c505a356f691aade5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a26f3dce99502455905ee8a98832f63fd59af391121d10045343b3a21130fa04b8bf78326a13b8f1df6d73d365a6651c2526074a1a623a8432b58c8fcfc70686
|
7
|
+
data.tar.gz: 4e4432deac0dc8732c6934e3b8cf79b650fb9e28417f894a7a68886e907f795d5cd084f687023578920da58eedaffc9f0a277026a45346c29547368dd6699153
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 3.1.1
|
2
|
+
- Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
|
3
|
+
|
4
|
+
## 3.1.0
|
5
|
+
- Log and tag attempts to split invalid types instead of crashing logstash
|
1
6
|
## 3.0.1
|
2
7
|
- Republish all the gems under jruby.
|
3
8
|
## 3.0.0
|
@@ -7,7 +12,6 @@
|
|
7
12
|
# 2.0.3
|
8
13
|
- New dependency requirements for logstash-core for the 5.0 release
|
9
14
|
## 2.0.0
|
10
|
-
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
15
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
11
16
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
12
17
|
- Dependency on logstash-core update to 2.0
|
13
|
-
|
@@ -11,17 +11,47 @@ require "logstash/namespace"
|
|
11
11
|
# the whole output of a command and splitting that output by newline -
|
12
12
|
# making each line an event.
|
13
13
|
#
|
14
|
+
# Split filter can also be used to split array fields in events into individual events.
|
15
|
+
# A very common pattern in JSON & XML is to make use of lists to group data together.
|
16
|
+
#
|
17
|
+
# For example, a json structure like this:
|
18
|
+
#
|
19
|
+
# [source,js]
|
20
|
+
# ----------------------------------
|
21
|
+
# { field1: ...,
|
22
|
+
# results: [
|
23
|
+
# { result ... },
|
24
|
+
# { result ... },
|
25
|
+
# { result ... },
|
26
|
+
# ...
|
27
|
+
# ] }
|
28
|
+
# ----------------------------------
|
29
|
+
#
|
30
|
+
# The split filter can be used on the above data to create separate events for each value of `results` field
|
31
|
+
#
|
32
|
+
# [source,js]
|
33
|
+
# ----------------------------------
|
34
|
+
# filter {
|
35
|
+
# split {
|
36
|
+
# field => "results"
|
37
|
+
# }
|
38
|
+
# }
|
39
|
+
# ----------------------------------
|
40
|
+
#
|
14
41
|
# The end result of each split is a complete copy of the event
|
15
42
|
# with only the current split section of the given field changed.
|
16
43
|
class LogStash::Filters::Split < LogStash::Filters::Base
|
44
|
+
PARSE_FAILURE_TAG = '_split_type_failure'.freeze
|
17
45
|
|
18
46
|
config_name "split"
|
19
47
|
|
20
48
|
# The string to split on. This is usually a line terminator, but can be any
|
21
|
-
# string.
|
49
|
+
# string. If you are splitting a JSON array into multiple events, you can ignore this field.
|
22
50
|
config :terminator, :validate => :string, :default => "\n"
|
23
51
|
|
24
|
-
# The field
|
52
|
+
# The field which value is split by the terminator.
|
53
|
+
# Can be a multiline message or the ID of an array.
|
54
|
+
# Nested arrays are referenced like: "[object_id][array_id]"
|
25
55
|
config :field, :validate => :string, :default => "message"
|
26
56
|
|
27
57
|
# The field within the new event which the value is split into.
|
@@ -46,7 +76,9 @@ class LogStash::Filters::Split < LogStash::Filters::Base
|
|
46
76
|
# splits.
|
47
77
|
splits = original_value.split(@terminator, -1)
|
48
78
|
else
|
49
|
-
|
79
|
+
logger.warn("Only String and Array types are splittable. field:#{@field} is of type = #{original_value.class}")
|
80
|
+
event.tag(PARSE_FAILURE_TAG)
|
81
|
+
return
|
50
82
|
end
|
51
83
|
|
52
84
|
# Skip filtering if splitting this event resulted in only one thing found.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-split'
|
4
|
-
s.version = '3.
|
4
|
+
s.version = '3.1.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "The split filter is for splitting multiline messages into separate events."
|
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"
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core-plugin-api", "
|
23
|
+
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
24
24
|
|
25
25
|
s.add_development_dependency 'logstash-devutils'
|
26
26
|
end
|
data/spec/filters/split_spec.rb
CHANGED
@@ -101,10 +101,21 @@ describe LogStash::Filters::Split do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
context "when invalid type is passed" do
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
let(:filter) { LogStash::Filters::Split.new({"field" => "field"}) }
|
105
|
+
let(:logger) { filter.logger }
|
106
|
+
let(:event) { event = LogStash::Event.new("field" => 10) }
|
107
|
+
|
108
|
+
before do
|
109
|
+
allow(filter.logger).to receive(:warn).with(anything)
|
110
|
+
filter.filter(event)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should log an error" do
|
114
|
+
expect(filter.logger).to have_received(:warn).with(/Only String and Array types are splittable/)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should add a '_splitparsefailure' tag" do
|
118
|
+
expect(event.get("tags")).to include(LogStash::Filters::Split::PARSE_FAILURE_TAG)
|
108
119
|
end
|
109
120
|
end
|
110
121
|
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-split
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-14 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
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.60'
|
19
|
+
- - "<="
|
17
20
|
- !ruby/object:Gem::Version
|
18
|
-
version: '2.
|
21
|
+
version: '2.99'
|
19
22
|
name: logstash-core-plugin-api
|
20
23
|
prerelease: false
|
21
24
|
type: :runtime
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.60'
|
30
|
+
- - "<="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
32
|
+
version: '2.99'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
requirement: !ruby/object:Gem::Requirement
|
29
35
|
requirements:
|
@@ -75,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
81
|
version: '0'
|
76
82
|
requirements: []
|
77
83
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.6.3
|
79
85
|
signing_key:
|
80
86
|
specification_version: 4
|
81
87
|
summary: The split filter is for splitting multiline messages into separate events.
|