logstash-filter-split 3.1.6 → 3.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe030f91f29f8ff0430df5dfd10383768f638791b8c0daff31b6c812ee5da2f1
4
- data.tar.gz: 1f62b67442999091a356fda0475dfa57c1f1b721050e6ecee1fc388f0315084c
3
+ metadata.gz: 3356dcc11862987712e4f9052ce4bc58be208f8f92d5cea69b23532e5b6ac603
4
+ data.tar.gz: af3d58b3f1677c1fe0269673d5e37286cb2947d2ac705bfdfdce94fcc8a0c080
5
5
  SHA512:
6
- metadata.gz: 1ec5139936cada2b3ae96193e74604ff271f5a7bfda523f39d7309e0fce259dbbec70767d0595c75db9efa1e4a4a6e0b52888e3dc264391b35ed32c45a6e5f53
7
- data.tar.gz: dc6a646310aea30b1ddbf0fda097e648063277e53442e0afb9c5daadecc5f78509bc848cf8ecc9f86bbfb9f23afac473dd1d772141b7cae409455022eec5d375
6
+ metadata.gz: f62920048aff417db5f8166cad3db2457fe5183b94e22ad9ec240a7c5dc858b5b2230e5b9fe79e25b86b5fc4362566f4265fdbbfe0bf573942e952a5bf8deefb
7
+ data.tar.gz: a0af9cda51ef388c88d3d1102a3ffa74711559a1e3b53d9616acd550ae294a0b0118874d0c23d90ad0a58ecaa4ac94516d4ae03dcb9a4e39465f85146a0f40da
@@ -1,3 +1,6 @@
1
+ ## 3.1.7
2
+ - Fixed numeric values, optimized @target verification, cleanups and specs [36](https://github.com/logstash-plugins/logstash-filter-split/pull/36)
3
+
1
4
  ## 3.1.6
2
5
  - Fix crash on arrays with null values
3
6
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
1
+ Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -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
- <<plugins-inputs-exec,exec input plugin>> which emits one event for
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
- # Nothing to do
64
- end # def register
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
- @logger.debug("Split event", :value => value, :field => @field)
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 # def filter
107
- end # class LogStash::Filters::Split
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.6'
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"
@@ -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.6
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: 2017-12-11 00:00:00.000000000 Z
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