logstash-output-file 0.1.1 → 0.1.2
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/lib/logstash/outputs/file.rb +5 -4
- data/logstash-output-file.gemspec +1 -1
- data/spec/outputs/file_spec.rb +38 -0
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76aac0c5cc726eb75e9e861aae50fc240a965449
|
4
|
+
data.tar.gz: c6096e0f9f1bdbac7c1a604922ae8edf704a8bec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7eb2b5b22b9eca84937fd2841206f7fcfa3328a24cd61bc3ed84c697c5b1aca8650c88d95f409915cad0b14d6716e6a5091991686175a46efc2fcf5776350ef1
|
7
|
+
data.tar.gz: 845be053f7c8e8a79caec2060d3b8d8b601d5676bcd7a55563e1f18775d8cb1a47621b2b0f6a86d183574b0e4e1ed0b074d1013d9b24a68c4d802ccf738da02c
|
@@ -7,6 +7,7 @@ require "zlib"
|
|
7
7
|
# This output will write events to files on disk. You can use fields
|
8
8
|
# from the event as parts of the filename and/or path.
|
9
9
|
class LogStash::Outputs::File < LogStash::Outputs::Base
|
10
|
+
FIELD_REF = /%\{[^}]+\}/
|
10
11
|
|
11
12
|
config_name "file"
|
12
13
|
milestone 2
|
@@ -78,7 +79,7 @@ class LogStash::Outputs::File < LogStash::Outputs::Base
|
|
78
79
|
def validate_path
|
79
80
|
root_directory = @path.split(File::SEPARATOR).select { |item| !item.empty? }.shift
|
80
81
|
|
81
|
-
if (root_directory =~
|
82
|
+
if (root_directory =~ FIELD_REF) != nil
|
82
83
|
@logger.error("File: The starting part of the path should not be dynamic.", :path => @path)
|
83
84
|
raise LogStash::ConfigurationError.new("The starting part of the path should not be dynamic.")
|
84
85
|
end
|
@@ -126,7 +127,7 @@ class LogStash::Outputs::File < LogStash::Outputs::Base
|
|
126
127
|
|
127
128
|
private
|
128
129
|
def path_with_field_ref?
|
129
|
-
path =~
|
130
|
+
path =~ FIELD_REF
|
130
131
|
end
|
131
132
|
|
132
133
|
def format_message(event)
|
@@ -138,8 +139,8 @@ class LogStash::Outputs::File < LogStash::Outputs::Base
|
|
138
139
|
end
|
139
140
|
|
140
141
|
def extract_file_root
|
141
|
-
|
142
|
-
|
142
|
+
parts = File.expand_path(path).split(File::SEPARATOR)
|
143
|
+
parts.take_while { |part| part !~ FIELD_REF }.join(File::SEPARATOR)
|
143
144
|
end
|
144
145
|
|
145
146
|
def teardown
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-file'
|
4
|
-
s.version = '0.1.
|
4
|
+
s.version = '0.1.2'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This output will write events to files on disk"
|
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"
|
data/spec/outputs/file_spec.rb
CHANGED
@@ -186,6 +186,44 @@ describe LogStash::Outputs::File do
|
|
186
186
|
end
|
187
187
|
end
|
188
188
|
|
189
|
+
it 'write the events to a file when some part of a folder or file is dynamic' do
|
190
|
+
t = Time.now
|
191
|
+
good_event = LogStash::Event.new("@timestamp" => t)
|
192
|
+
|
193
|
+
Stud::Temporary.directory do |path|
|
194
|
+
dynamic_path = "#{path}/failed_syslog-%{+YYYY-MM-dd}"
|
195
|
+
expected_path = "#{path}/failed_syslog-#{t.strftime("%Y-%m-%d")}"
|
196
|
+
|
197
|
+
config = { "path" => dynamic_path }
|
198
|
+
output = LogStash::Outputs::File.new(config)
|
199
|
+
output.register
|
200
|
+
output.receive(good_event)
|
201
|
+
|
202
|
+
expect(File.exist?(expected_path)).to eq(true)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'write the events to the generated path containing multiples fieldref' do
|
207
|
+
t = Time.now
|
208
|
+
good_event = LogStash::Event.new("error" => 42,
|
209
|
+
"@timestamp" => t,
|
210
|
+
"level" => "critical",
|
211
|
+
"weird_path" => '/inside/../deep/nested')
|
212
|
+
|
213
|
+
Stud::Temporary.directory do |path|
|
214
|
+
dynamic_path = "#{path}/%{error}/%{level}/%{weird_path}/failed_syslog-%{+YYYY-MM-dd}"
|
215
|
+
expected_path = "#{path}/42/critical/deep/nested/failed_syslog-#{t.strftime("%Y-%m-%d")}"
|
216
|
+
|
217
|
+
config = { "path" => dynamic_path }
|
218
|
+
|
219
|
+
output = LogStash::Outputs::File.new(config)
|
220
|
+
output.register
|
221
|
+
output.receive(good_event)
|
222
|
+
|
223
|
+
expect(File.exist?(expected_path)).to eq(true)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
189
227
|
it 'write the event to the generated filename with multiple deep' do
|
190
228
|
good_event = LogStash::Event.new
|
191
229
|
good_event['error'] = '/inside/errors/42.txt'
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elasticsearch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
14
|
+
name: logstash
|
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: 2.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,34 +28,36 @@ dependencies:
|
|
30
28
|
- - <
|
31
29
|
- !ruby/object:Gem::Version
|
32
30
|
version: 2.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-input-generator
|
40
45
|
prerelease: false
|
41
46
|
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-devutils
|
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-devutils
|
54
59
|
prerelease: false
|
55
60
|
type: :development
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - '>='
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
61
|
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
|
62
62
|
email: info@elasticsearch.com
|
63
63
|
executables: []
|