logstash-input-lumberjack 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c95ed8c335834c6e16f56a92efa111ed21cf306
4
- data.tar.gz: d82b929b991d94d8d50ac0e1100515acbd589670
3
+ metadata.gz: 12038c6ea1977ded3c29e696b911c450aef2637a
4
+ data.tar.gz: 155669c9a27b5ce28a72c44dc56cb4ad5d23fc3f
5
5
  SHA512:
6
- metadata.gz: 247305962c11c14a6c48ea8bc024cb77a1c0a20f30e9089f913f54028f921eecd1222b4c0dc98f403c66286882b25769efbd58858e47cee46c5d29b178f31f03
7
- data.tar.gz: f77f1b128dde2933c6728915d7dbfb4b771b6ff33645e1c328e52ef5fb8b438f5c2be8b74fba913204dd9f8e3e18a41367e708a7513ea803c16a4cb713ea6d1e
6
+ metadata.gz: 3948d3bac4c844e4cc45a05122d85dbb1647e9c8c644aed09c0dcbbc2b5e1a7b31d6180564aa0a5db5a9218e671d17e0b28ba1857b39576be49d304ff352f587
7
+ data.tar.gz: ed7708a847723a48ca267811a4de238fd895ebfee0d1c3e550004de2e25b3ee0b710055646172b2f707f11bb2a7fe6eacdf39e343c173f3a9e1dd43c4479bea7
@@ -4,7 +4,7 @@ require "logstash/namespace"
4
4
 
5
5
  # Receive events using the lumberjack protocol.
6
6
  #
7
- # This is mainly to receive events shipped with lumberjack[http://github.com/jordansissel/lumberjack],
7
+ # This is mainly to receive events shipped with lumberjack[http://github.com/jordansissel/lumberjack],
8
8
  # now represented primarily via the
9
9
  # https://github.com/elasticsearch/logstash-forwarder[Logstash-forwarder].
10
10
  #
@@ -43,12 +43,35 @@ class LogStash::Inputs::Lumberjack < LogStash::Inputs::Base
43
43
 
44
44
  public
45
45
  def run(output_queue)
46
- @lumberjack.run do |l|
47
- @codec.decode(l.delete("line")) do |event|
48
- decorate(event)
49
- l.each { |k,v| event[k] = v; v.force_encoding(Encoding::UTF_8) }
50
- output_queue << event
46
+ while true do
47
+ accept do |connection, codec|
48
+ invoke(connection, codec) do |_codec, line, fields|
49
+ _codec.decode(line) do |event|
50
+ decorate(event)
51
+ fields.each { |k,v| event[k] = v; v.force_encoding(Encoding::UTF_8) }
52
+ output_queue << event
53
+ end
54
+ end
51
55
  end
52
56
  end
57
+ rescue => e
58
+ @logger.error("Exception in lumberjack input", :exception => e)
59
+ shutdown(output_queue)
53
60
  end # def run
61
+
62
+ private
63
+ def accept(&block)
64
+ connection = @lumberjack.accept # Blocking call that creates a new connection
65
+ block.call(connection, @codec.clone)
66
+ end
67
+
68
+ private
69
+ def invoke(connection, codec, &block)
70
+ Thread.new(connection, codec) do |_connection, _codec|
71
+ _connection.run do |fields|
72
+ block.call(_codec, fields.delete("line"), fields)
73
+ end
74
+ end
75
+ end
76
+
54
77
  end # class LogStash::Inputs::Lumberjack
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-lumberjack'
4
- s.version = '0.1.3'
4
+ s.version = '0.1.4'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Receive events using the lumberjack protocol."
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"
@@ -26,5 +26,8 @@ Gem::Specification.new do |s|
26
26
  s.add_runtime_dependency 'jls-lumberjack', ['>=0.0.20']
27
27
 
28
28
  s.add_development_dependency 'logstash-devutils'
29
+ s.add_development_dependency 'stud'
30
+ s.add_development_dependency 'logstash-codec-multiline'
31
+
29
32
  end
30
33
 
@@ -1 +1,57 @@
1
- require "logstash/devutils/rspec/spec_helper"
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "stud/temporary"
4
+ require 'logstash/inputs/lumberjack'
5
+ require "logstash/codecs/plain"
6
+ require "logstash/codecs/multiline"
7
+
8
+ describe LogStash::Inputs::Lumberjack do
9
+
10
+ let(:ssl_cert) { Stud::Temporary.pathname("ssl_certificate") }
11
+ let(:ssl_key) { Stud::Temporary.pathname("ssl_key") }
12
+
13
+ let(:queue) { Queue.new }
14
+ let(:config) { { "port" => 0, "ssl_certificate" => ssl_cert, "ssl_key" => ssl_key, "type" => "example" } }
15
+
16
+
17
+ before do
18
+ system("openssl req -x509 -batch -nodes -newkey rsa:2048 -keyout #{ssl_key} -out #{ssl_cert} -subj /CN=localhost > /dev/null 2>&1")
19
+ end
20
+
21
+ context "#register" do
22
+
23
+ it "raise no exception" do
24
+ plugin = LogStash::Inputs::Lumberjack.new(config)
25
+ expect { plugin.register}.not_to raise_error
26
+ end
27
+ end
28
+
29
+ describe "#processing of events" do
30
+
31
+ context "#codecs" do
32
+
33
+ let(:config) do
34
+ { "port" => 6969, "ssl_certificate" => ssl_cert, "ssl_key" => ssl_key,
35
+ "type" => "example", "codec" => codec }
36
+ end
37
+
38
+ let(:codec) { LogStash::Codecs::Multiline.new("pattern" => '\n', "what" => "previous") }
39
+ subject!(:lumberjack) { LogStash::Inputs::Lumberjack.new(config) }
40
+ let(:connection) { double("connection") }
41
+ let(:lines) { {"line" => "one\ntwo\n two.2\nthree\n"} }
42
+
43
+ before(:each) do
44
+ allow(connection).to receive(:run).and_yield(lines)
45
+ lumberjack.register
46
+ end
47
+
48
+ it "clone the codec per connection" do
49
+ expect_any_instance_of(Lumberjack::Server).to receive(:accept).and_return(connection)
50
+ expect(lumberjack.codec).to receive(:clone).once
51
+ expect(lumberjack).to receive(:invoke).and_throw(:msg)
52
+ lumberjack.run(queue)
53
+ end
54
+
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,2 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/codecs/plain"
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-lumberjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elasticsearch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-26 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
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: 2.0.0
22
- name: logstash-core
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,78 @@ 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-codec-plain
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-codec-plain
40
45
  prerelease: false
41
46
  type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: jls-lumberjack
42
49
  version_requirements: !ruby/object:Gem::Requirement
43
50
  requirements:
44
51
  - - '>='
45
52
  - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
53
+ version: 0.0.20
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  requirements:
50
56
  - - '>='
51
57
  - !ruby/object:Gem::Version
52
58
  version: 0.0.20
53
- name: jls-lumberjack
54
59
  prerelease: false
55
60
  type: :runtime
61
+ - !ruby/object:Gem::Dependency
62
+ name: logstash-devutils
56
63
  version_requirements: !ruby/object:Gem::Requirement
57
64
  requirements:
58
65
  - - '>='
59
66
  - !ruby/object:Gem::Version
60
- version: 0.0.20
67
+ version: '0'
68
+ requirement: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ prerelease: false
74
+ type: :development
61
75
  - !ruby/object:Gem::Dependency
76
+ name: stud
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
62
82
  requirement: !ruby/object:Gem::Requirement
63
83
  requirements:
64
84
  - - '>='
65
85
  - !ruby/object:Gem::Version
66
86
  version: '0'
67
- name: logstash-devutils
68
87
  prerelease: false
69
88
  type: :development
89
+ - !ruby/object:Gem::Dependency
90
+ name: logstash-codec-multiline
70
91
  version_requirements: !ruby/object:Gem::Requirement
71
92
  requirements:
72
93
  - - '>='
73
94
  - !ruby/object:Gem::Version
74
95
  version: '0'
96
+ requirement: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ prerelease: false
102
+ type: :development
75
103
  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
104
  email: info@elasticsearch.com
77
105
  executables: []
@@ -87,6 +115,7 @@ files:
87
115
  - lib/logstash/inputs/lumberjack.rb
88
116
  - logstash-input-lumberjack.gemspec
89
117
  - spec/inputs/lumberjack_spec.rb
118
+ - spec/spec_helper.rb
90
119
  homepage: http://www.elasticsearch.org/guide/en/logstash/current/index.html
91
120
  licenses:
92
121
  - Apache License (2.0)
@@ -109,9 +138,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
138
  version: '0'
110
139
  requirements: []
111
140
  rubyforge_project:
112
- rubygems_version: 2.4.5
141
+ rubygems_version: 2.1.9
113
142
  signing_key:
114
143
  specification_version: 4
115
144
  summary: Receive events using the lumberjack protocol.
116
145
  test_files:
117
146
  - spec/inputs/lumberjack_spec.rb
147
+ - spec/spec_helper.rb