logstash-filter-split 3.1.6 → 3.1.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 +3 -0
- data/LICENSE +1 -1
- data/docs/index.asciidoc +2 -2
- data/lib/logstash/filters/split.rb +8 -16
- data/logstash-filter-split.gemspec +1 -1
- data/spec/filters/split_spec.rb +36 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3356dcc11862987712e4f9052ce4bc58be208f8f92d5cea69b23532e5b6ac603
|
4
|
+
data.tar.gz: af3d58b3f1677c1fe0269673d5e37286cb2947d2ac705bfdfdce94fcc8a0c080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f62920048aff417db5f8166cad3db2457fe5183b94e22ad9ec240a7c5dc858b5b2230e5b9fe79e25b86b5fc4362566f4265fdbbfe0bf573942e952a5bf8deefb
|
7
|
+
data.tar.gz: a0af9cda51ef388c88d3d1102a3ffa74711559a1e3b53d9616acd550ae294a0b0118874d0c23d90ad0a58ecaa4ac94516d4ae03dcb9a4e39465f85146a0f40da
|
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
data/docs/index.asciidoc
CHANGED
@@ -25,7 +25,7 @@ placing each value resulting from the split into a clone of the original
|
|
25
25
|
event. The field being split can either be a string or an array.
|
26
26
|
|
27
27
|
An example use case of this filter is for taking output from the
|
28
|
-
|
28
|
+
{logstash-ref}/plugins-inputs-exec.html[exec input plugin] which emits one event for
|
29
29
|
the whole output of a command and splitting that output by newline -
|
30
30
|
making each line an event.
|
31
31
|
|
@@ -108,4 +108,4 @@ string. If you are splitting a JSON array into multiple events, you can ignore t
|
|
108
108
|
|
109
109
|
|
110
110
|
[id="plugins-{type}s-{plugin}-common-options"]
|
111
|
-
include::{include_path}/{type}.asciidoc[]
|
111
|
+
include::{include_path}/{type}.asciidoc[]
|
@@ -58,15 +58,12 @@ class LogStash::Filters::Split < LogStash::Filters::Base
|
|
58
58
|
# If not set, the target field defaults to split field name.
|
59
59
|
config :target, :validate => :string
|
60
60
|
|
61
|
-
public
|
62
61
|
def register
|
63
|
-
#
|
64
|
-
|
62
|
+
# set @target to @field if not configured
|
63
|
+
@target ||= @field
|
64
|
+
end
|
65
65
|
|
66
|
-
public
|
67
66
|
def filter(event)
|
68
|
-
|
69
|
-
|
70
67
|
original_value = event.get(@field)
|
71
68
|
|
72
69
|
if original_value.is_a?(Array)
|
@@ -83,18 +80,13 @@ class LogStash::Filters::Split < LogStash::Filters::Base
|
|
83
80
|
|
84
81
|
# Skip filtering if splitting this event resulted in only one thing found.
|
85
82
|
return if splits.length == 1 && original_value.is_a?(String)
|
86
|
-
#or splits[1].empty?
|
87
83
|
|
88
84
|
splits.each do |value|
|
89
|
-
next if value.nil? || value.empty?
|
85
|
+
next if value.nil? || (value.is_a?(String) && value.empty?)
|
86
|
+
@logger.debug? && @logger.debug("Split event", :value => value, :field => @field)
|
90
87
|
|
91
88
|
event_split = event.clone
|
92
|
-
|
93
|
-
if @target.nil?
|
94
|
-
event_split.set(@field, value)
|
95
|
-
else
|
96
|
-
event_split.set(@target, value)
|
97
|
-
end
|
89
|
+
event_split.set(@target, value)
|
98
90
|
filter_matched(event_split)
|
99
91
|
|
100
92
|
# Push this new event onto the stack at the LogStash::FilterWorker
|
@@ -103,5 +95,5 @@ class LogStash::Filters::Split < LogStash::Filters::Base
|
|
103
95
|
|
104
96
|
# Cancel this event, we'll use the newly generated ones above.
|
105
97
|
event.cancel
|
106
|
-
end
|
107
|
-
end
|
98
|
+
end
|
99
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-split'
|
4
|
-
s.version = '3.1.
|
4
|
+
s.version = '3.1.7'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Splits multi-line messages into distinct 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"
|
data/spec/filters/split_spec.rb
CHANGED
@@ -122,6 +122,42 @@ describe LogStash::Filters::Split do
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
+
describe "split array of numerics" do
|
126
|
+
config <<-CONFIG
|
127
|
+
filter {
|
128
|
+
split {
|
129
|
+
field => "array"
|
130
|
+
target => "element"
|
131
|
+
}
|
132
|
+
}
|
133
|
+
CONFIG
|
134
|
+
|
135
|
+
sample("array" => [1, 2, 3]) do
|
136
|
+
insist { subject.length } == 3
|
137
|
+
insist { subject[0].get("element") } == 1
|
138
|
+
insist { subject[1].get("element") } == 2
|
139
|
+
insist { subject[2].get("element") } == 3
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "split array of numerics and strings" do
|
144
|
+
config <<-CONFIG
|
145
|
+
filter {
|
146
|
+
split {
|
147
|
+
field => "array"
|
148
|
+
target => "element"
|
149
|
+
}
|
150
|
+
}
|
151
|
+
CONFIG
|
152
|
+
|
153
|
+
sample("array" => [1, 2, "three", ""]) do
|
154
|
+
insist { subject.length } == 3
|
155
|
+
insist { subject[0].get("element") } == 1
|
156
|
+
insist { subject[1].get("element") } == 2
|
157
|
+
insist { subject[2].get("element") } == "three"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
125
161
|
context "when invalid type is passed" do
|
126
162
|
let(:filter) { LogStash::Filters::Split.new({"field" => "field"}) }
|
127
163
|
let(:logger) { filter.logger }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-split
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.7
|
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: 2019-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|