logstash-input-mongodb 0.3.2 → 0.3.3
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/README.md +6 -0
- data/lib/logstash/inputs/mongodb.rb +12 -9
- data/logstash-input-mongodb.gemspec +1 -1
- data/spec/inputs/mongodb_spec.rb +81 -0
- metadata +4 -4
- data/spec/inputs/example_spec.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 388af0f33d8e7e99f421dfb5f178b213b394fbb8
|
4
|
+
data.tar.gz: a5275546392e3c9c588f266e9d84f5c8124af36b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e61433c0e8d75fcb990c7353d5ba5edb3af08a5ae924696b40f8ad2b0e0e4a2edef4d71a204caf2b6d7dc439b85db24983edade05f1725c3fa713284974583d5
|
7
|
+
data.tar.gz: 45321ea60084617ea0e917632b072cd12eae3a6098de2712dc3a8eb4b15738cb164821e17daee8b92ec29c04c8f17c686767726338c6c131476055ca38245862
|
data/README.md
CHANGED
@@ -69,3 +69,9 @@ output {
|
|
69
69
|
}
|
70
70
|
}
|
71
71
|
```
|
72
|
+
|
73
|
+
### MongoDB URI
|
74
|
+
|
75
|
+
The URI parameter is where you would specify all of your mongodb options including things like auth and SSL. You should use a connection string (URI) compatible with the mongodb spec.
|
76
|
+
|
77
|
+
For more information on MongoDB URI's please see the MongoDB documentation: https://docs.mongodb.org/v3.0/reference/connection-string/
|
@@ -213,10 +213,11 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
213
213
|
sleep_max = 5
|
214
214
|
sleeptime = sleep_min
|
215
215
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
216
|
+
@logger.debug("Tailing MongoDB")
|
217
|
+
@logger.debug("Collection data is: #{@collection_data}")
|
218
|
+
|
219
|
+
while true && !stop?
|
220
|
+
begin
|
220
221
|
@collection_data.each do |index, collection|
|
221
222
|
collection_name = collection[:name]
|
222
223
|
@logger.debug("collection_data is: #{@collection_data}")
|
@@ -341,13 +342,15 @@ class LogStash::Inputs::MongoDB < LogStash::Inputs::Base
|
|
341
342
|
@logger.debug("No new rows. Sleeping.", :time => sleeptime)
|
342
343
|
sleeptime = [sleeptime * 2, sleep_max].min
|
343
344
|
sleep(sleeptime)
|
344
|
-
|
345
|
-
|
346
|
-
rescue LogStash::ShutdownSignal
|
347
|
-
if @interrupted
|
348
|
-
@logger.debug("Mongo Input shutting down")
|
345
|
+
rescue => e
|
346
|
+
@logger.warn('MongoDB Input threw an exception, restarting', :exception => e)
|
349
347
|
end
|
350
348
|
end
|
351
349
|
end # def run
|
352
350
|
|
351
|
+
def close
|
352
|
+
# If needed, use this to tidy up on shutdown
|
353
|
+
@logger.debug("Shutting down...")
|
354
|
+
end
|
355
|
+
|
353
356
|
end # class LogStash::Inputs::Example
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-mongodb'
|
3
|
-
s.version = '0.3.
|
3
|
+
s.version = '0.3.3'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "This takes entries from mongodb as an input to logstash."
|
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"
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "logstash/devutils/rspec/spec_helper"
|
4
|
+
require "tempfile"
|
5
|
+
require "stud/temporary"
|
6
|
+
require "logstash/inputs/mongodb"
|
7
|
+
|
8
|
+
FILE_DELIMITER = LogStash::Environment.windows? ? "\r\n" : "\n"
|
9
|
+
|
10
|
+
describe LogStash::Inputs::Mongodb do
|
11
|
+
before(:all) do
|
12
|
+
@abort_on_exception = Thread.abort_on_exception
|
13
|
+
Thread.abort_on_exception = true
|
14
|
+
end
|
15
|
+
|
16
|
+
after(:all) do
|
17
|
+
Thread.abort_on_exception = @abort_on_exception
|
18
|
+
end
|
19
|
+
|
20
|
+
it_behaves_like "an interruptible input plugin" do
|
21
|
+
let(:config) do
|
22
|
+
{
|
23
|
+
placeholder_db_dir => Stud::Temporary.pathname,
|
24
|
+
placeholder_db_bame => Stud::Temporary.file,
|
25
|
+
collection => 'logstash-input-mongodb_test'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should start at the beginning of a collection when no sincedb data exists" do
|
31
|
+
placeholder_db_dir = Stud::Temporary.pathname
|
32
|
+
placeholder_db_name = Stud::Temporary.pathname
|
33
|
+
collection = 'logstash-input-mongodb_test'
|
34
|
+
|
35
|
+
conf = <<-CONFIG
|
36
|
+
input {
|
37
|
+
mongodb {
|
38
|
+
uri => 'mongodb://localhost/logstash-input-mongodb_test',
|
39
|
+
placeholder_db_dir => "#{placeholder_db_dir}"
|
40
|
+
placeholder_db_name => "#{placeholder_db_name}"
|
41
|
+
collection => "#{collection}"
|
42
|
+
}
|
43
|
+
}
|
44
|
+
CONFIG
|
45
|
+
|
46
|
+
# Create the test DB and populate it with some data
|
47
|
+
# add "first message"
|
48
|
+
# add "second message"
|
49
|
+
|
50
|
+
events = input(conf) do |pipeline, queue|
|
51
|
+
|
52
|
+
events = []
|
53
|
+
|
54
|
+
retries = 0
|
55
|
+
while retries < 20
|
56
|
+
# Add some new entries to the database
|
57
|
+
# add "third message"
|
58
|
+
# add "fourth message"
|
59
|
+
|
60
|
+
if queue.size >= 4
|
61
|
+
events = 4.times.collect { queue.pop }
|
62
|
+
break
|
63
|
+
end
|
64
|
+
|
65
|
+
sleep(0.1)
|
66
|
+
retries += 1
|
67
|
+
end
|
68
|
+
|
69
|
+
events
|
70
|
+
end
|
71
|
+
|
72
|
+
insist { events[0]["message"] } == "first message"
|
73
|
+
insist { events[1]["message"] } == "second message"
|
74
|
+
insist { events[2]["message"] } == "third message"
|
75
|
+
insist { events[3]["message"] } == "fourth message"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should start where it left off in a collection when it has sincedb data" do
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-mongodb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Hutchins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -128,7 +128,7 @@ files:
|
|
128
128
|
- README.md
|
129
129
|
- lib/logstash/inputs/mongodb.rb
|
130
130
|
- logstash-input-mongodb.gemspec
|
131
|
-
- spec/inputs/
|
131
|
+
- spec/inputs/mongodb_spec.rb
|
132
132
|
homepage: http://www.phutchins.com
|
133
133
|
licenses:
|
134
134
|
- Apache License (2.0)
|
@@ -156,4 +156,4 @@ signing_key:
|
|
156
156
|
specification_version: 4
|
157
157
|
summary: This takes entries from mongodb as an input to logstash.
|
158
158
|
test_files:
|
159
|
-
- spec/inputs/
|
159
|
+
- spec/inputs/mongodb_spec.rb
|
data/spec/inputs/example_spec.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "logstash/devutils/rspec/spec_helper"
|