logstash-input-jsqs 0.9.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85191dce09f154911ff8d1a2b5d076472bf275c6
4
+ data.tar.gz: 6bac1f35c24c0f04b87072a1e3d359ab742f1e45
5
+ SHA512:
6
+ metadata.gz: 86639ab9e5ee0bd507d407ac76d5d0e98eb8ceb299ddb39a0ab442f41d2423173cbca96e44b132855537fac0fdb57abc953472b64513d7a6a1e7af544042cf79
7
+ data.tar.gz: 52b578a50de497436eaaa8a708a9d8230942290c7fef80414bbc82a832660795b77a64231da2469d9efac9857c31d4cf8f9a056e7c96390d34dbe981b37464dc
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ Gemfile.bak
4
+ .bundle
data/CHANGELOG.md ADDED
File without changes
data/DEVELOPER.md ADDED
@@ -0,0 +1 @@
1
+ # logstash-input-jsqs
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2015 Jamie Cressey <jamiecressey89@gmail.com>
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.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
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.elasticsearch.org/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/elasticsearch/docs#asciidoc-guide
13
+
14
+ ## Need Help?
15
+
16
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
+
18
+ ## Developing
19
+
20
+ ### 1. Plugin Developement and Testing
21
+
22
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - 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).
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ - Update your dependencies
35
+
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ - Run tests
41
+
42
+ ```sh
43
+ bundle exec rspec
44
+ ```
45
+
46
+ ### 2. Running your unpublished Plugin in Logstash
47
+
48
+ #### 2.1 Run in a local Logstash clone
49
+
50
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
51
+ ```ruby
52
+ gem "logstash-input-jsqs", :path => "/your/local/logstash-input-jsqs"
53
+ ```
54
+ - Install plugin
55
+ ```sh
56
+ bin/plugin install --no-verify
57
+ ```
58
+ - Run Logstash with your plugin
59
+ ```sh
60
+ bin/logstash -e 'input {jsqs {queueUrl => "https://sqs.eu-west-1.amazonaws.com/xxxxxxxxxxxx/logstash-queue"}}'
61
+ ```
62
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
+
64
+ #### 2.2 Run in an installed Logstash
65
+
66
+ 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:
67
+
68
+ - Build your plugin gem
69
+ ```sh
70
+ gem build logstash-input-jsqs.gemspec
71
+ ```
72
+ - Install the plugin from the Logstash home
73
+ ```sh
74
+ bin/plugin install /your/local/plugin/logstash-input-jsqs.gem
75
+ ```
76
+ - Start Logstash and proceed to test the plugin
77
+
78
+ ## Contributing
79
+
80
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
+
82
+ 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.
83
+
84
+ It is more important to the community that you are able to contribute.
85
+
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rake"
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ require 'logstash/environment'
3
+
4
+ root_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
5
+ LogStash::Environment.load_runtime_jars! File.join(root_dir, "vendor")
6
+
7
+ java_import "com.amazonaws.services.sqs.model.DeleteMessageBatchRequestEntry"
8
+ java_import "java.util.concurrent.Executors"
9
+ java_import "java.util.concurrent.atomic.AtomicInteger"
10
+ java_import "com.amazonaws.ClientConfiguration"
11
+ java_import "com.amazonaws.services.sqs.AmazonSQSAsyncClient"
12
+ java_import "com.amazonaws.services.sqs.buffered.AmazonSQSBufferedAsyncClient"
13
+ java_import "com.amazonaws.services.sqs.buffered.QueueBufferConfig"
14
+ java_import "com.amazonaws.services.sqs.model.ReceiveMessageRequest"
15
+ java_import "com.amazonaws.services.sqs.model.DeleteMessageBatchRequest"
@@ -0,0 +1,156 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/threadable"
3
+ require "logstash/namespace"
4
+ require "logstash/plugin_mixins/aws_config"
5
+ require "digest/sha2"
6
+ require 'logstash-input-jsqs_jars.rb'
7
+
8
+ # aws-java-sdk dependencies
9
+ # require 'jar/aws-java-sdk.jar'
10
+ # require 'jar/httpclient-4.2.jar'
11
+ # require 'jar/httpcore-4.2.jar'
12
+ # require 'jar/commons-codec-1.6'
13
+ # require 'jar/jackson-core-2.1.1.jar'
14
+ # require 'jar/jackson-databind-2.1.1.jar'
15
+ # require 'jar/jackson-annotations-2.1.1.jar'
16
+ #
17
+
18
+ # Pull events from an Amazon Web Services Simple Queue Service (SQS) queue.
19
+ #
20
+ # SQS is a simple, scalable queue system that is part of the
21
+ # Amazon Web Services suite of tools.
22
+ #
23
+ # Although SQS is similar to other queuing systems like AMQP, it
24
+ # uses a custom API and requires that you have an AWS account.
25
+ # See http://aws.amazon.com/sqs/ for more details on how SQS works,
26
+ # what the pricing schedule looks like and how to setup a queue.
27
+ #
28
+ # To use this plugin, you *must*:
29
+ #
30
+ # * Have an AWS account
31
+ # * Setup an SQS queue
32
+ # * Create an identify that has access to consume messages from the queue.
33
+ #
34
+ # The "consumer" identity must have the following permissions on the queue:
35
+ #
36
+ # * sqs:ChangeMessageVisibility
37
+ # * sqs:ChangeMessageVisibilityBatch
38
+ # * sqs:DeleteMessage
39
+ # * sqs:DeleteMessageBatch
40
+ # * sqs:GetQueueAttributes
41
+ # * sqs:GetQueueUrl
42
+ # * sqs:ListQueues
43
+ # * sqs:ReceiveMessage
44
+ #
45
+ # Typically, you should setup an IAM policy, create a user and apply the IAM policy to the user.
46
+ # A sample policy is as follows:
47
+ #
48
+ # {
49
+ # "Statement": [
50
+ # {
51
+ # "Action": [
52
+ # "sqs:ChangeMessageVisibility",
53
+ # "sqs:ChangeMessageVisibilityBatch",
54
+ # "sqs:GetQueueAttributes",
55
+ # "sqs:GetQueueUrl",
56
+ # "sqs:ListQueues",
57
+ # "sqs:SendMessage",
58
+ # "sqs:SendMessageBatch"
59
+ # ],
60
+ # "Effect": "Allow",
61
+ # "Resource": [
62
+ # "arn:aws:sqs:us-east-1:123456789012:Logstash"
63
+ # ]
64
+ # }
65
+ # ]
66
+ # }
67
+ #
68
+ # See http://aws.amazon.com/iam/ for more details on setting up AWS identities.
69
+ #
70
+
71
+ # -------------------------------------
72
+ # NOTICE:
73
+ # This is a custom SQS input that uses the Java AWS SDK (Ruby SDK didn't scale beyond 200 messages per second).
74
+ # This plugin assumes that the logstash distribution contains the Java AWS SDK its required dependencies.
75
+ # In Logstash 1.3.3, Apache HTTP client (4.1) had to be removed from the Logstash distribution,
76
+ # as it was incompatible with the Apache HTTP client 4.2 version used by the Java AWS SDK.
77
+ # -------------------------------------
78
+
79
+ class LogStash::Inputs::JSQS < LogStash::Inputs::Threadable
80
+
81
+ config_name "jsqs"
82
+
83
+ default :codec, "json"
84
+
85
+ # Name of the SQS Queue name to pull messages from. Note that this is just the name of the queue, not the URL or ARN.
86
+ config :queueUrl, :validate => :string, :required => true
87
+ config :max_connections, :validate => :number, :default => 1000
88
+ config :max_batch_open_ms, :validate => :number, :default => 5000
89
+ config :max_inflight_receive_batches, :validate => :number, :default => 50
90
+ config :max_done_receive_batches, :validate => :number, :default => 50
91
+ config :max_number_of_messages, :validate => :number, :default => 10
92
+
93
+ @receiveRequest
94
+
95
+ public
96
+ def register
97
+
98
+ @logger.info("Registering SQS input", :queue => @queue)
99
+
100
+ begin
101
+ # Client config
102
+ @logger.debug("Creating AWS SQS queue client", :queue => @queue)
103
+ clientConfig = ClientConfiguration.new.withMaxConnections(@max_connections)
104
+ # SQS client
105
+ @sqs = AmazonSQSAsyncClient.new(clientConfig)
106
+ @logger.debug("Amazon SQS Client created")
107
+
108
+ # Buffered client config
109
+ queueBufferConfig = QueueBufferConfig.new.withMaxBatchOpenMs(@max_batch_open_ms).withMaxInflightReceiveBatches(@max_inflight_receive_batches).withMaxDoneReceiveBatches(@max_done_receive_batches)
110
+
111
+ @bufferedSqs = AmazonSQSBufferedAsyncClient.new(@sqs, queueBufferConfig);
112
+ @logger.info("Connected to AWS SQS queue successfully.", :queue => @queue)
113
+
114
+ @receiveRequest = ReceiveMessageRequest.new(@queueUrl).withMaxNumberOfMessages(@max_number_of_messages)
115
+
116
+ rescue Exception => e
117
+ @logger.error("Unable to access SQS queue.", :error => e.to_s, :queue => @queue)
118
+ throw e
119
+ end # begin/rescue
120
+
121
+ end # def register
122
+
123
+ public
124
+ def run(output_queue)
125
+ @logger.debug("Polling SQS queue", :queue => @queue)
126
+
127
+ while running?
128
+ result = @bufferedSqs.receiveMessage(@receiveRequest)
129
+ deleteEntries = []
130
+ # Process messages (expected 0 - 10 messages)
131
+ result.messages.each_with_index { |message, i|
132
+ @codec.decode(message.body) do |event|
133
+ decorate(event)
134
+ output_queue << event
135
+ end # codec.decode
136
+
137
+ #Add Delete entry for this message
138
+ deleteEntries << DeleteMessageBatchRequestEntry.new.withId(i.to_s).withReceiptHandle(message.getReceiptHandle())
139
+ }
140
+ if deleteEntries.size > 0
141
+ deleteRequest = DeleteMessageBatchRequest.new.withQueueUrl(@queueUrl);
142
+ deleteRequest.setEntries(deleteEntries);
143
+ # Issue delete request
144
+ @bufferedSqs.deleteMessageBatch(deleteRequest);
145
+ end # end if
146
+
147
+ end # polling loop
148
+ end # def run
149
+
150
+ def teardown
151
+ @sqs = nil
152
+ @bufferedSqs = nil
153
+ finished
154
+ end # def teardown
155
+
156
+ end # class LogStash::Inputs::SQS
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.platform = RUBY_PLATFORM
3
+ s.name = 'logstash-input-jsqs'
4
+ s.version = '0.9.1'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "SQS input plugin using the AWS Java SDK"
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 logstash-input-jsqs. This gem is not a stand-alone program"
8
+ s.authors = ["Jamie Cressey"]
9
+ s.email = 'jamiecressey89@gmail.com'
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = `git ls-files`.split($\)
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', '>= 1.4.0', '< 2.0.0'
22
+ s.add_development_dependency 'logstash-devutils'
23
+
24
+ end
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-jsqs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: java
6
+ authors:
7
+ - Jamie Cressey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-04 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: 1.4.0
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 2.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: 1.4.0
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: logstash-devutils
40
+ prerelease: false
41
+ type: :development
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ 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-jsqs. This gem is not a stand-alone program
48
+ email: jamiecressey89@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - CHANGELOG.md
55
+ - DEVELOPER.md
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - lib/logstash-input-jsqs_jars.rb
61
+ - lib/logstash/inputs/jsqs.rb
62
+ - logstash-input-jsqs.gemspec
63
+ - spec/inputs/example_spec.rb
64
+ - vendor/jar-dependencies/runtime-jars/aws-java-sdk-1.7.13.jar
65
+ - vendor/jar-dependencies/runtime-jars/commons-codec-1.9.jar
66
+ - vendor/jar-dependencies/runtime-jars/commons-logging-1.2.jar
67
+ - vendor/jar-dependencies/runtime-jars/httpclient-4.4.jar
68
+ - vendor/jar-dependencies/runtime-jars/httpcore-4.4.1.jar
69
+ - vendor/jar-dependencies/runtime-jars/jackson-annotations-2.5.1.jar
70
+ - vendor/jar-dependencies/runtime-jars/jackson-core-2.5.1.jar
71
+ - vendor/jar-dependencies/runtime-jars/jackson-databind-2.5.1.jar
72
+ - vendor/jar-dependencies/runtime-jars/joda-time-2.7.jar
73
+ homepage:
74
+ licenses:
75
+ - Apache License (2.0)
76
+ metadata:
77
+ logstash_plugin: 'true'
78
+ logstash_group: input
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.8
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: SQS input plugin using the AWS Java SDK
99
+ test_files:
100
+ - spec/inputs/example_spec.rb