logstash-output-csv 2.0.2 → 2.0.3
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 +4 -2
- data/README.md +3 -0
- data/lib/logstash/outputs/csv.rb +10 -3
- data/logstash-output-csv.gemspec +2 -2
- data/spec/outputs/csv_spec.rb +53 -1
- metadata +27 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05d5e4ca59e34c3669b05517154b5b5869d483c7
|
4
|
+
data.tar.gz: b27171ebca8cef47f85fa94dbe89aa5facb23c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b41a43e2c69186d9a4ccb1ec5557dc029ee5cad34b480cdf4fbe674823f4500336662ea47715a5e7de6e895f6982e75828c03377f6a23891c5f26e8dd69567f4
|
7
|
+
data.tar.gz: b88038d2a6a36646809d5ecf5a553755a92c6e2a4f06b5f9a6b9a6806995f25f6f719bd4f046419d2f6b2bfb4c79b9e878b75a57f6d231c0d3b241b1238311b3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
## 2.0.3
|
2
|
+
- Escape rogue values by default, which can be interpreted by spreadsheet apps. Add option to turn it off
|
3
|
+
|
1
4
|
## 2.0.0
|
2
|
-
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
5
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
3
6
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
4
7
|
- Dependency on logstash-core update to 2.0
|
5
|
-
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
+
[](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-csv-unit/)
|
5
|
+
|
3
6
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
7
|
|
5
8
|
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
data/lib/logstash/outputs/csv.rb
CHANGED
@@ -22,6 +22,9 @@ class LogStash::Outputs::CSV < LogStash::Outputs::File
|
|
22
22
|
# Full documentation is available on the http://ruby-doc.org/stdlib-2.0.0/libdoc/csv/rdoc/index.html[Ruby CSV documentation page].
|
23
23
|
# A typical use case would be to use alternative column or row seperators eg: `csv_options => {"col_sep" => "\t" "row_sep" => "\r\n"}` gives tab seperated data with windows line endings
|
24
24
|
config :csv_options, :validate => :hash, :required => false, :default => Hash.new
|
25
|
+
# Option to not escape/munge string values. Please note turning off this option
|
26
|
+
# may not make the values safe in your spreadsheet application
|
27
|
+
config :spreadsheet_safe, :validate => :boolean, :default => true
|
25
28
|
|
26
29
|
public
|
27
30
|
def register
|
@@ -31,7 +34,7 @@ class LogStash::Outputs::CSV < LogStash::Outputs::File
|
|
31
34
|
|
32
35
|
public
|
33
36
|
def receive(event)
|
34
|
-
|
37
|
+
|
35
38
|
path = event.sprintf(@path)
|
36
39
|
fd = open(path)
|
37
40
|
csv_values = @fields.map {|name| get_value(name, event)}
|
@@ -44,7 +47,11 @@ class LogStash::Outputs::CSV < LogStash::Outputs::File
|
|
44
47
|
private
|
45
48
|
def get_value(name, event)
|
46
49
|
val = event[name]
|
47
|
-
val.is_a?(Hash) ? LogStash::Json.dump(val) : val
|
50
|
+
val.is_a?(Hash) ? LogStash::Json.dump(val) : escape_csv(val)
|
48
51
|
end
|
49
|
-
end # class LogStash::Outputs::CSV
|
50
52
|
|
53
|
+
private
|
54
|
+
def escape_csv(val)
|
55
|
+
(spreadsheet_safe && val.is_a?(String) && val.start_with?("=")) ? "'#{val}" : val
|
56
|
+
end
|
57
|
+
end # class LogStash::Outputs::CSV
|
data/logstash-output-csv.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-csv'
|
4
|
-
s.version = '2.0.
|
4
|
+
s.version = '2.0.3'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Write events to disk in CSV or other delimited format"
|
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"
|
@@ -22,8 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
# Gem dependencies
|
23
23
|
s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
|
24
24
|
|
25
|
+
s.add_runtime_dependency 'logstash-input-generator'
|
25
26
|
s.add_runtime_dependency 'logstash-output-file'
|
26
27
|
s.add_runtime_dependency 'logstash-filter-json'
|
27
28
|
s.add_development_dependency 'logstash-devutils'
|
28
29
|
end
|
29
|
-
|
data/spec/outputs/csv_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require "logstash/devutils/rspec/spec_helper"
|
|
4
4
|
require "logstash/outputs/csv"
|
5
5
|
|
6
6
|
describe LogStash::Outputs::CSV do
|
7
|
-
|
7
|
+
|
8
8
|
|
9
9
|
describe "Write a single field to a csv file" do
|
10
10
|
tmpfile = Tempfile.new('logstash-spec-output-csv')
|
@@ -263,4 +263,56 @@ describe LogStash::Outputs::CSV do
|
|
263
263
|
insist {lines[0]} == "one|two\tone|two\t"
|
264
264
|
end
|
265
265
|
end
|
266
|
+
|
267
|
+
describe "can escape rogue values" do
|
268
|
+
tmpfile = Tempfile.new('logstash-spec-output-csv')
|
269
|
+
config <<-CONFIG
|
270
|
+
input {
|
271
|
+
generator {
|
272
|
+
add_field => ["foo","1+1", "baz", "=1+1"]
|
273
|
+
count => 1
|
274
|
+
}
|
275
|
+
}
|
276
|
+
output {
|
277
|
+
csv {
|
278
|
+
path => "#{tmpfile.path}"
|
279
|
+
fields => ["foo", "baz"]
|
280
|
+
}
|
281
|
+
}
|
282
|
+
CONFIG
|
283
|
+
|
284
|
+
agent do
|
285
|
+
lines = CSV.read(tmpfile.path)
|
286
|
+
insist {lines.count} == 1
|
287
|
+
insist {lines[0][0]} == "1+1"
|
288
|
+
insist {lines[0][1]} == "'=1+1"
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe "can turn off escaping rogue values" do
|
293
|
+
tmpfile = Tempfile.new('logstash-spec-output-csv')
|
294
|
+
config <<-CONFIG
|
295
|
+
input {
|
296
|
+
generator {
|
297
|
+
add_field => ["foo","1+1", "baz", "=1+1"]
|
298
|
+
count => 1
|
299
|
+
}
|
300
|
+
}
|
301
|
+
output {
|
302
|
+
csv {
|
303
|
+
path => "#{tmpfile.path}"
|
304
|
+
spreadsheet_safe => false
|
305
|
+
fields => ["foo", "baz"]
|
306
|
+
}
|
307
|
+
}
|
308
|
+
CONFIG
|
309
|
+
|
310
|
+
agent do
|
311
|
+
lines = CSV.read(tmpfile.path)
|
312
|
+
insist {lines.count} == 1
|
313
|
+
insist {lines[0][0]} == "1+1"
|
314
|
+
insist {lines[0][1]} == "=1+1"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
266
318
|
end
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
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: 2016-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
14
|
+
name: logstash-core
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - '>='
|
17
18
|
- !ruby/object:Gem::Version
|
@@ -19,10 +20,7 @@ dependencies:
|
|
19
20
|
- - <
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 3.0.0
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
type: :runtime
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
26
24
|
requirements:
|
27
25
|
- - '>='
|
28
26
|
- !ruby/object:Gem::Version
|
@@ -30,48 +28,64 @@ dependencies:
|
|
30
28
|
- - <
|
31
29
|
- !ruby/object:Gem::Version
|
32
30
|
version: 3.0.0
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
+
name: logstash-input-generator
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
34
40
|
requirement: !ruby/object:Gem::Requirement
|
35
41
|
requirements:
|
36
42
|
- - '>='
|
37
43
|
- !ruby/object:Gem::Version
|
38
44
|
version: '0'
|
39
|
-
name: logstash-output-file
|
40
45
|
prerelease: false
|
41
46
|
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-output-file
|
42
49
|
version_requirements: !ruby/object:Gem::Requirement
|
43
50
|
requirements:
|
44
51
|
- - '>='
|
45
52
|
- !ruby/object:Gem::Version
|
46
53
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
54
|
requirement: !ruby/object:Gem::Requirement
|
49
55
|
requirements:
|
50
56
|
- - '>='
|
51
57
|
- !ruby/object:Gem::Version
|
52
58
|
version: '0'
|
53
|
-
name: logstash-filter-json
|
54
59
|
prerelease: false
|
55
60
|
type: :runtime
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: logstash-filter-json
|
56
63
|
version_requirements: !ruby/object:Gem::Requirement
|
57
64
|
requirements:
|
58
65
|
- - '>='
|
59
66
|
- !ruby/object:Gem::Version
|
60
67
|
version: '0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
68
|
requirement: !ruby/object:Gem::Requirement
|
63
69
|
requirements:
|
64
70
|
- - '>='
|
65
71
|
- !ruby/object:Gem::Version
|
66
72
|
version: '0'
|
67
|
-
name: logstash-devutils
|
68
73
|
prerelease: false
|
69
|
-
type: :
|
74
|
+
type: :runtime
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: logstash-devutils
|
70
77
|
version_requirements: !ruby/object:Gem::Requirement
|
71
78
|
requirements:
|
72
79
|
- - '>='
|
73
80
|
- !ruby/object:Gem::Version
|
74
81
|
version: '0'
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
prerelease: false
|
88
|
+
type: :development
|
75
89
|
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
|
76
90
|
email: info@elastic.co
|
77
91
|
executables: []
|