logstash-input-sqs 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/logstash/inputs/sqs.rb +2 -16
- data/logstash-input-sqs.gemspec +3 -3
- data/spec/inputs/sqs_spec.rb +34 -6
- metadata +21 -29
- data/.gitignore +0 -4
- data/Rakefile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2ff09888677156e06aae67eee1791aadd5ec0e
|
4
|
+
data.tar.gz: b9b80b1bea2c09bfa757afdec78502f9716d2281
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7a86a835f37601ae8cab2dab1e1c0b2cff4124eac04f4ec76044a37488640625b2154d0359867b364e92621352d4395c955c604c6f592f4ec0a52eb305c02f
|
7
|
+
data.tar.gz: 72a7e6174f6181ddc8cf9dec32172ee1a56451d053233eaf3ef750be7a20529e87ffeddc4f08f5f029e967ab1ceccb83faba769c561146033b0ceb054dc7da5a
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
This is a plugin for [Logstash](https://github.com/
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
4
|
|
5
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
6
|
|
7
7
|
## Documentation
|
8
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.
|
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
10
|
|
11
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/
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
83
83
|
|
84
84
|
It is more important to the community that you are able to contribute.
|
85
85
|
|
86
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/lib/logstash/inputs/sqs.rb
CHANGED
@@ -94,7 +94,6 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
|
|
94
94
|
require "aws-sdk"
|
95
95
|
@logger.info("Registering SQS input", :queue => @queue)
|
96
96
|
|
97
|
-
monkey_patch_aws_retryable_plugin!
|
98
97
|
setup_queue
|
99
98
|
end
|
100
99
|
|
@@ -141,6 +140,8 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
|
|
141
140
|
|
142
141
|
run_with_backoff do
|
143
142
|
poller.poll(polling_options) do |messages, stats|
|
143
|
+
break if stop?
|
144
|
+
|
144
145
|
messages.each do |message|
|
145
146
|
output_queue << handle_message(message)
|
146
147
|
end
|
@@ -171,25 +172,10 @@ class LogStash::Inputs::SQS < LogStash::Inputs::Threadable
|
|
171
172
|
next_sleep = next_sleep > max_time ? sleep_time : sleep_time * BACKOFF_FACTOR
|
172
173
|
|
173
174
|
retry
|
174
|
-
rescue LogStash::ShutdownSignal
|
175
|
-
# The pipeline is currently shutting down.
|
176
|
-
# we can safely rescue and return, all unacked sqs messages will be resend
|
177
|
-
# when the pipeline is up again.
|
178
175
|
end
|
179
176
|
end
|
180
177
|
|
181
178
|
def convert_epoch_to_timestamp(time)
|
182
179
|
LogStash::Timestamp.at(time.to_i / 1000)
|
183
180
|
end
|
184
|
-
|
185
|
-
def monkey_patch_aws_retryable_plugin!
|
186
|
-
Aws::Plugins::RetryErrors::ErrorInspector.module_eval do
|
187
|
-
def networking?
|
188
|
-
!@error.is_a?(LogStash::ShutdownSignal) &&
|
189
|
-
(@error.is_a?(Seahorse::Client::NetworkingError) ||
|
190
|
-
Aws::Plugins::RetryErrors::ErrorInspector::NETWORKING_ERRORS.include?(@name) ||
|
191
|
-
@http_status_code == 0)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
181
|
end # class LogStash::Inputs::SQS
|
data/logstash-input-sqs.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-sqs'
|
3
|
-
s.version = '
|
3
|
+
s.version = '2.0.0'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Pull events from an Amazon Web Services Simple Queue Service (SQS) queue."
|
6
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 gemname. This gem is not a stand-alone program"
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.require_paths = ["lib"]
|
11
11
|
|
12
12
|
# Files
|
13
|
-
s.files =
|
13
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
14
14
|
|
15
15
|
# Tests
|
16
16
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
20
20
|
|
21
21
|
# Gem dependencies
|
22
|
-
s.add_runtime_dependency "logstash-core",
|
22
|
+
s.add_runtime_dependency "logstash-core", "~> 2.0.0.snapshot"
|
23
23
|
|
24
24
|
s.add_runtime_dependency 'logstash-codec-json'
|
25
25
|
s.add_runtime_dependency "logstash-mixin-aws", ">= 1.0.0"
|
data/spec/inputs/sqs_spec.rb
CHANGED
@@ -5,11 +5,12 @@ require "logstash/event"
|
|
5
5
|
require "logstash/json"
|
6
6
|
require "aws-sdk"
|
7
7
|
require "spec_helper"
|
8
|
+
require "ostruct"
|
8
9
|
|
9
10
|
describe LogStash::Inputs::SQS do
|
10
11
|
let(:queue_name) { "the-infinite-pandora-box" }
|
11
|
-
let(:queue_url) { "https://sqs.test.local/#{
|
12
|
-
let(:
|
12
|
+
let(:queue_url) { "https://sqs.test.local/#{queue_name}" }
|
13
|
+
let(:config) do
|
13
14
|
{
|
14
15
|
"region" => "us-east-1",
|
15
16
|
"access_key_id" => "123",
|
@@ -18,8 +19,7 @@ describe LogStash::Inputs::SQS do
|
|
18
19
|
}
|
19
20
|
end
|
20
21
|
|
21
|
-
let(:input) { LogStash::Inputs::SQS.new(
|
22
|
-
|
22
|
+
let(:input) { LogStash::Inputs::SQS.new(config) }
|
23
23
|
let(:decoded_message) { { "bonjour" => "awesome" } }
|
24
24
|
let(:encoded_message) { double("sqs_message", :body => LogStash::Json::dump(decoded_message)) }
|
25
25
|
|
@@ -27,6 +27,7 @@ describe LogStash::Inputs::SQS do
|
|
27
27
|
|
28
28
|
let(:mock_sqs) { Aws::SQS::Client.new({ :stub_responses => true }) }
|
29
29
|
|
30
|
+
|
30
31
|
context "with invalid credentials" do
|
31
32
|
before do
|
32
33
|
expect(Aws::SQS::Client).to receive(:new).and_return(mock_sqs)
|
@@ -47,6 +48,33 @@ describe LogStash::Inputs::SQS do
|
|
47
48
|
expect { subject.register }.not_to raise_error
|
48
49
|
end
|
49
50
|
|
51
|
+
context "when interrupting the plugin" do
|
52
|
+
before do
|
53
|
+
expect(Aws::SQS::Client).to receive(:new).and_return(mock_sqs)
|
54
|
+
expect(mock_sqs).to receive(:get_queue_url).with({ :queue_name => queue_name }).and_return({:queue_url => queue_url })
|
55
|
+
expect(subject).to receive(:poller).and_return(mock_sqs).at_least(:once)
|
56
|
+
|
57
|
+
# We have to make sure we create a bunch of events
|
58
|
+
# so we actually really try to stop the plugin.
|
59
|
+
#
|
60
|
+
# rspec's `and_yield` allow you to define a fix amount of possible
|
61
|
+
# yielded values and doesn't allow you to create infinite loop.
|
62
|
+
# And since we are actually creating thread we need to make sure
|
63
|
+
# we have enough work to keep the thread working until we kill it..
|
64
|
+
#
|
65
|
+
# I haven't found a way to make it rspec friendly
|
66
|
+
mock_sqs.instance_eval do
|
67
|
+
def poll(polling_options = {})
|
68
|
+
loop do
|
69
|
+
yield [OpenStruct.new(:body => LogStash::Json::dump({ "message" => "hello world"}))], OpenStruct.new
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it_behaves_like "an interruptible input plugin"
|
76
|
+
end
|
77
|
+
|
50
78
|
context "enrich event" do
|
51
79
|
let(:event) { LogStash::Event.new }
|
52
80
|
|
@@ -66,7 +94,7 @@ describe LogStash::Inputs::SQS do
|
|
66
94
|
subject { input.add_sqs_data(event, message) }
|
67
95
|
|
68
96
|
context "when the option is specified" do
|
69
|
-
let(:
|
97
|
+
let(:config) do
|
70
98
|
{
|
71
99
|
"region" => "us-east-1",
|
72
100
|
"access_key_id" => "123",
|
@@ -107,7 +135,7 @@ describe LogStash::Inputs::SQS do
|
|
107
135
|
end
|
108
136
|
|
109
137
|
context "when decoding body" do
|
110
|
-
subject { LogStash::Inputs::SQS::new(
|
138
|
+
subject { LogStash::Inputs::SQS::new(config.merge({ "codec" => "json" })) }
|
111
139
|
|
112
140
|
it "uses the specified codec" do
|
113
141
|
expect(subject.decode_event(encoded_message)["bonjour"]).to eq(decoded_message["bonjour"])
|
metadata
CHANGED
@@ -1,91 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-sqs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: logstash-core
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.4.0
|
20
|
-
- - <
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 2.0.0
|
23
14
|
requirement: !ruby/object:Gem::Requirement
|
24
15
|
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 1.4.0
|
28
|
-
- - <
|
16
|
+
- - ~>
|
29
17
|
- !ruby/object:Gem::Version
|
30
|
-
version: 2.0.0
|
18
|
+
version: 2.0.0.snapshot
|
19
|
+
name: logstash-core
|
31
20
|
prerelease: false
|
32
21
|
type: :runtime
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: logstash-codec-json
|
35
22
|
version_requirements: !ruby/object:Gem::Requirement
|
36
23
|
requirements:
|
37
|
-
- -
|
24
|
+
- - ~>
|
38
25
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
26
|
+
version: 2.0.0.snapshot
|
27
|
+
- !ruby/object:Gem::Dependency
|
40
28
|
requirement: !ruby/object:Gem::Requirement
|
41
29
|
requirements:
|
42
30
|
- - '>='
|
43
31
|
- !ruby/object:Gem::Version
|
44
32
|
version: '0'
|
33
|
+
name: logstash-codec-json
|
45
34
|
prerelease: false
|
46
35
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: logstash-mixin-aws
|
49
36
|
version_requirements: !ruby/object:Gem::Requirement
|
50
37
|
requirements:
|
51
38
|
- - '>='
|
52
39
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
54
42
|
requirement: !ruby/object:Gem::Requirement
|
55
43
|
requirements:
|
56
44
|
- - '>='
|
57
45
|
- !ruby/object:Gem::Version
|
58
46
|
version: 1.0.0
|
47
|
+
name: logstash-mixin-aws
|
59
48
|
prerelease: false
|
60
49
|
type: :runtime
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: logstash-devutils
|
63
50
|
version_requirements: !ruby/object:Gem::Requirement
|
64
51
|
requirements:
|
65
52
|
- - '>='
|
66
53
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
54
|
+
version: 1.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
68
56
|
requirement: !ruby/object:Gem::Requirement
|
69
57
|
requirements:
|
70
58
|
- - '>='
|
71
59
|
- !ruby/object:Gem::Version
|
72
60
|
version: '0'
|
61
|
+
name: logstash-devutils
|
73
62
|
prerelease: false
|
74
63
|
type: :development
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
75
69
|
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
70
|
email: info@elastic.co
|
77
71
|
executables: []
|
78
72
|
extensions: []
|
79
73
|
extra_rdoc_files: []
|
80
74
|
files:
|
81
|
-
- .gitignore
|
82
75
|
- CHANGELOG.md
|
83
76
|
- CONTRIBUTORS
|
84
77
|
- Gemfile
|
85
78
|
- LICENSE
|
86
79
|
- NOTICE.TXT
|
87
80
|
- README.md
|
88
|
-
- Rakefile
|
89
81
|
- lib/logstash/inputs/sqs.rb
|
90
82
|
- logstash-input-sqs.gemspec
|
91
83
|
- spec/inputs/sqs_spec.rb
|
@@ -114,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
106
|
version: '0'
|
115
107
|
requirements: []
|
116
108
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.4.8
|
118
110
|
signing_key:
|
119
111
|
specification_version: 4
|
120
112
|
summary: Pull events from an Amazon Web Services Simple Queue Service (SQS) queue.
|
data/.gitignore
DELETED