logstash-filter-csv 3.0.5 → 3.0.6
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/lib/logstash/filters/csv.rb +7 -3
- data/logstash-filter-csv.gemspec +1 -1
- data/spec/filters/csv_spec.rb +54 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ff0bd6fdf58706e32acf77c116694d1274b7d11
|
4
|
+
data.tar.gz: 28b97ce191613e3245376d2c21475623c4a0f985
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1533f34f35e0701ae830109a548f0ff1d260147c99e36f4fd82ebdb2700a22d7500da3edb48bc15c549c2e63fa529967017d7f11b3e4e009e1977ced0b21b29
|
7
|
+
data.tar.gz: a04d372cb6114b935828ec6de9ca6d2821c1afab13287819b200f2ca3f1196e638368be53e78e40da5878ad7a405f5d3d51ea2774de99c34982bc17c304dd020
|
data/CHANGELOG.md
CHANGED
data/lib/logstash/filters/csv.rb
CHANGED
@@ -105,7 +105,7 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
|
|
105
105
|
@convert_symbols = @convert.inject({}){|result, (k, v)| result[k] = v.to_sym; result}
|
106
106
|
|
107
107
|
# make sure @target is in the format [field name] if defined, i.e. surrounded by brakets
|
108
|
-
@target = "[#{@target}]" if @target &&
|
108
|
+
@target = "[#{@target}]" if @target && !@target.start_with?("[")
|
109
109
|
|
110
110
|
# if the zero byte character is entered in the config, set the value
|
111
111
|
if (@quote_char == "\\x00")
|
@@ -151,10 +151,14 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
|
|
151
151
|
private
|
152
152
|
|
153
153
|
# construct the correct Event field reference for given field_name, taking into account @target
|
154
|
-
# @param field_name [String] the
|
154
|
+
# @param field_name [String] the field name.
|
155
155
|
# @return [String] fully qualified Event field reference also taking into account @target prefix
|
156
156
|
def field_ref(field_name)
|
157
|
-
"
|
157
|
+
if field_name.start_with?("[")
|
158
|
+
"#{@target}#{field_name}"
|
159
|
+
else
|
160
|
+
"#{@target}[#{field_name}]"
|
161
|
+
end
|
158
162
|
end
|
159
163
|
|
160
164
|
def ignore_field?(index)
|
data/logstash-filter-csv.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-csv'
|
4
|
-
s.version = '3.0.
|
4
|
+
s.version = '3.0.6'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "The CSV filter takes an event field containing CSV data, parses it, and stores it as individual fields (can optionally specify the names)."
|
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/csv_spec.rb
CHANGED
@@ -196,6 +196,25 @@ describe LogStash::Filters::CSV do
|
|
196
196
|
expect(event.get("custom3")).to eq("val3")
|
197
197
|
end
|
198
198
|
end
|
199
|
+
|
200
|
+
context "that use [@metadata]" do
|
201
|
+
let(:metadata_field) { "[@metadata][one]" }
|
202
|
+
let(:config) do
|
203
|
+
{
|
204
|
+
"columns" => [ metadata_field, "foo" ]
|
205
|
+
}
|
206
|
+
end
|
207
|
+
|
208
|
+
let(:event) { LogStash::Event.new("message" => "hello,world") }
|
209
|
+
|
210
|
+
before do
|
211
|
+
plugin.filter(event)
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should work correctly" do
|
215
|
+
expect(event.get(metadata_field)).to eq("hello")
|
216
|
+
end
|
217
|
+
end
|
199
218
|
end
|
200
219
|
|
201
220
|
describe "givin target" do
|
@@ -227,6 +246,41 @@ describe LogStash::Filters::CSV do
|
|
227
246
|
expect(event.get("data")["column3"]).to eq("sesame street")
|
228
247
|
end
|
229
248
|
end
|
249
|
+
|
250
|
+
context "which uses [nested][fieldref] syntax" do
|
251
|
+
let(:target) { "[foo][bar]" }
|
252
|
+
let(:config) do
|
253
|
+
{
|
254
|
+
"target" => target
|
255
|
+
}
|
256
|
+
end
|
257
|
+
|
258
|
+
let(:event) { LogStash::Event.new("message" => "hello,world") }
|
259
|
+
|
260
|
+
before do
|
261
|
+
plugin.filter(event)
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should set fields correctly in the target" do
|
265
|
+
expect(event.get("#{target}[column1]")).to eq("hello")
|
266
|
+
expect(event.get("#{target}[column2]")).to eq("world")
|
267
|
+
end
|
268
|
+
|
269
|
+
context "with nested fieldrefs as columns" do
|
270
|
+
let(:config) do
|
271
|
+
{
|
272
|
+
"target" => target,
|
273
|
+
"columns" => [ "[test][one]", "[test][two]" ]
|
274
|
+
}
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should set fields correctly in the target" do
|
278
|
+
expect(event.get("#{target}[test][one]")).to eq("hello")
|
279
|
+
expect(event.get("#{target}[test][two]")).to eq("world")
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|
230
284
|
end
|
231
285
|
|
232
286
|
describe "using field convertion" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|