logstash-input-beanstalkd 0.9.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40851421c36c6a6d81fc949c667df64cb33fe8a9
4
+ data.tar.gz: 1a80a91dd097a382efdf88a28240e0c7c2c4cbe1
5
+ SHA512:
6
+ metadata.gz: d4eff4795374dcc6fb1332e8b9193a8fd17f3f84b44b562d245cb254fc33674c5e1b76fa7237c2d2c8dd765d1b8d2eb7085300053ca9214b739d261e2f8bb63f
7
+ data.tar.gz: 7e491b561f4ce66414a0bda6bc1dd2f9402fc55e6d92bee777ec17021e55026fd6d95336012d20ebb71dde1a210ab904f88edd164caa10613c761ebf9d891184
@@ -0,0 +1,5 @@
1
+ ## 1.0.0
2
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
4
+ - Dependency on logstash-core update to 2.0
5
+
@@ -0,0 +1 @@
1
+ # logstash-input-beanstalkd
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,106 @@
1
+ # Logstash Input Beanstalkd
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash) to fetch jobs from [beanstalkd](https://github.com/kr/beanstalkd).
4
+
5
+ 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.
6
+
7
+ ## Documentation
8
+
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
+
11
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
+
14
+ ### Installation
15
+ `bin/plugin install logstash-input-beanstalkd`
16
+
17
+ ### Sample Config
18
+ ```
19
+ input {
20
+ beanstalkd {
21
+ host => "localhost"
22
+ port => 11300
23
+ tube => "test"
24
+ priority => 5
25
+ delay => 5
26
+ ttr => 120
27
+ reserve_timeout => 5
28
+ }
29
+ }
30
+ ```
31
+ `port`, `priority`, `delay`, `ttr` and `reserve_timeout` are optional.
32
+ *NOTE*: This plugin assumes the job from beanstalkd is in json format !!!
33
+
34
+ ## Need Help?
35
+
36
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
37
+
38
+ ## Developing
39
+
40
+ ### 1. Plugin Developement and Testing
41
+
42
+ #### Code
43
+ - To get started, you'll need JRuby with the Bundler gem installed.
44
+
45
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
46
+
47
+ - Install dependencies
48
+ ```sh
49
+ bundle install
50
+ ```
51
+
52
+ #### Test
53
+
54
+ - Update your dependencies
55
+
56
+ ```sh
57
+ bundle install
58
+ ```
59
+
60
+ - Run tests
61
+
62
+ ```sh
63
+ bundle exec rspec
64
+ ```
65
+
66
+ ### 2. Running your unpublished Plugin in Logstash
67
+
68
+ #### 2.1 Run in a local Logstash clone
69
+
70
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
71
+ ```ruby
72
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
73
+ ```
74
+ - Install plugin
75
+ ```sh
76
+ bin/plugin install --no-verify
77
+ ```
78
+ - Run Logstash with your plugin
79
+ ```sh
80
+ bin/logstash -e 'filter {awesome {}}'
81
+ ```
82
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
83
+
84
+ #### 2.2 Run in an installed Logstash
85
+
86
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
87
+
88
+ - Build your plugin gem
89
+ ```sh
90
+ gem build logstash-filter-awesome.gemspec
91
+ ```
92
+ - Install the plugin from the Logstash home
93
+ ```sh
94
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
95
+ ```
96
+ - Start Logstash and proceed to test the plugin
97
+
98
+ ## Contributing
99
+
100
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
101
+
102
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
103
+
104
+ It is more important to the community that you are able to contribute.
105
+
106
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "beaneater"
5
+ require "json"
6
+
7
+ # This input will read jobs from a Beanstalk tube. It uses Beaneater(https://github.com/beanstalkd/beaneater)
8
+ # to interact with beanstalkd. The default input codec is json
9
+
10
+ class LogStash::Inputs::Beanstalkd < LogStash::Inputs::Base
11
+ config_name "beanstalkd"
12
+
13
+ # The address of the beanstalk server
14
+ config :host, :validate => :string, :required => true
15
+
16
+ # The port of your beanstalk server
17
+ config :port, :validate => :number, :default => 11300
18
+
19
+ # The name of the beanstalk tube
20
+ config :tube, :validate => :string, :required => true
21
+
22
+ # The priority of the job
23
+ config :priority, :validate => :number, :default => 1024
24
+
25
+ # The delay of the job in second
26
+ config :delay, :validate => :number, :default => 0
27
+
28
+ # The 'time to run' of the job
29
+ config :ttr, :validate => :number, :default => 120
30
+
31
+ # The reserve timeout of the job in second
32
+ config :reserve_timeout, :validate => :number, :default => 5
33
+
34
+ public
35
+ def register
36
+ Beaneater.configure do |config|
37
+ config.default_put_delay = @delay
38
+ config.default_put_pri = @priority
39
+ config.default_put_ttr = @ttr
40
+ end
41
+ @beanstalk = Beaneater.new("#{@host}:#{@port}")
42
+ @beanstalk.tubes.watch!(@tube)
43
+ end # def register
44
+
45
+ def run(queue)
46
+ while !stop?
47
+ begin
48
+ job = @beanstalk.tubes.reserve(@reserve_timeout)
49
+ event = LogStash::Event.new(JSON.parse(job.body))
50
+ decorate(event)
51
+ queue << event
52
+ job.delete
53
+ rescue IOError, EOFError, LogStash::ShutdownSignal => e
54
+ # stdin closed or a requested shutdown
55
+ break
56
+ rescue Beaneater::TimedOutError
57
+ # no job right now, just do another reserve
58
+ next
59
+ rescue => e
60
+ @logger.warn(["Trouble parsing beanstalk job",
61
+ {:error => e.message, :body => job.body,
62
+ :backtrace => e.backtrace}])
63
+ job.bury
64
+ end
65
+ end # loop
66
+ end # def run
67
+
68
+ def stop
69
+ @beanstalk.close
70
+ end
71
+ end # class LogStash::Inputs::Beanstalkd
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-input-beanstalkd'
3
+ s.version = '0.9.0.1'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "This input will read jobs from a beanstalk tube. It uses beaneater to interact with beanstalkd."
6
+ 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 logstash-input-beanstalkd. This gem is not a stand-alone program. It can read jobs from a beanstalk tube."
7
+ s.authors = ["Eagle Chen"]
8
+ s.email = "chygr1234@gmail.com"
9
+ s.homepage = "https://github.com/EagleChen/logstash-input-beanstalkd"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
22
+ s.add_runtime_dependency 'logstash-codec-plain', ">= 2.0.2", "< 3.0.0"
23
+ s.add_runtime_dependency "beaneater", ">= 1.0.0", "< 2.0.0"
24
+ s.add_development_dependency "logstash-devutils", ">= 0.0.16", "< 1.0.0"
25
+ end
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/inputs/beanstalkd"
4
+ require "beaneater"
5
+
6
+ describe LogStash::Inputs::Beanstalkd do
7
+ let (:valid_config) {{'host' => 'localhost', 'tube' => 'test'}}
8
+ let (:empty_config) {{}}
9
+ let (:non_default_config) {{'host' => 'localhost', 'tube' => 'test', 'priority' => 20, 'delay' => 10, 'ttr' => 10, 'reserve_timeout' => 5}}
10
+ let (:conf) {
11
+ <<-CONFIG
12
+ input {
13
+ beanstalkd {
14
+ host => "localhost"
15
+ tube => "test"
16
+ }
17
+ }
18
+ CONFIG
19
+ }
20
+
21
+ it "parse config" do
22
+ expect do
23
+ LogStash::Plugin.lookup("input", "beanstalkd").new(valid_config)
24
+ end.to_not raise_error
25
+ end
26
+
27
+ it "fails with empty config" do
28
+ expect do
29
+ LogStash::Plugin.lookup("input", "beanstalkd").new(valid_config)
30
+ end.to_not raise_error
31
+ end
32
+
33
+ it "can parse beanstalkd related data" do
34
+ expect do
35
+ LogStash::Plugin.lookup("input", "beanstalkd").new(valid_config)
36
+ end.to_not raise_error
37
+ end
38
+
39
+ # this test requires a running beanstalkd on localhost:11300
40
+ it "receive jobs" do
41
+ job = '{"test": 1}'
42
+ beanstalk = Beaneater.new('localhost:11300')
43
+ tube = beanstalk.tubes["test"]
44
+ tube.put job
45
+ beanstalk.close
46
+
47
+ result = input(conf) do |pipeline, queue|
48
+ queue.size.times.collect { queue.pop }
49
+ end
50
+
51
+ expect(result.size).to eq(1)
52
+ expect(result[0]["test"]).to eq(1)
53
+ end
54
+
55
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-beanstalkd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Eagle Chen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '>='
17
+ - !ruby/object:Gem::Version
18
+ version: 2.0.0
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ name: logstash-core
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: 2.0.2
39
+ - - <
40
+ - !ruby/object:Gem::Version
41
+ version: 3.0.0
42
+ name: logstash-codec-plain
43
+ prerelease: false
44
+ type: :runtime
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: 2.0.2
50
+ - - <
51
+ - !ruby/object:Gem::Version
52
+ version: 3.0.0
53
+ - !ruby/object:Gem::Dependency
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: 1.0.0
59
+ - - <
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.0
62
+ name: beaneater
63
+ prerelease: false
64
+ type: :runtime
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.0
70
+ - - <
71
+ - !ruby/object:Gem::Version
72
+ version: 2.0.0
73
+ - !ruby/object:Gem::Dependency
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: 0.0.16
79
+ - - <
80
+ - !ruby/object:Gem::Version
81
+ version: 1.0.0
82
+ name: logstash-devutils
83
+ prerelease: false
84
+ type: :development
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.0.16
90
+ - - <
91
+ - !ruby/object:Gem::Version
92
+ version: 1.0.0
93
+ description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install logstash-input-beanstalkd. This gem is not a stand-alone program. It can read jobs from a beanstalk tube.
94
+ email: chygr1234@gmail.com
95
+ executables: []
96
+ extensions: []
97
+ extra_rdoc_files: []
98
+ files:
99
+ - CHANGELOG.md
100
+ - DEVELOPER.md
101
+ - Gemfile
102
+ - LICENSE
103
+ - NOTICE.TXT
104
+ - README.md
105
+ - lib/logstash/inputs/beanstalkd.rb
106
+ - logstash-input-beanstalkd.gemspec
107
+ - spec/inputs/beanstalkd_spec.rb
108
+ homepage: https://github.com/EagleChen/logstash-input-beanstalkd
109
+ licenses:
110
+ - Apache License (2.0)
111
+ metadata:
112
+ logstash_plugin: 'true'
113
+ logstash_group: input
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.4.5
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: This input will read jobs from a beanstalk tube. It uses beaneater to interact with beanstalkd.
134
+ test_files:
135
+ - spec/inputs/beanstalkd_spec.rb