logstash-output-mongodb 3.0.1 → 3.1.0
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/CHANGELOG.md +3 -0
- data/lib/logstash/outputs/mongodb.rb +47 -1
- data/logstash-output-mongodb.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37c6554062844f26b2e5523500973e725f290ff0
|
4
|
+
data.tar.gz: 7a23d57d1bce56f1382eaf175d2513bcec133085
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bedf6b5a8e973d5a3a940b5ad9606719c4457a23be1947311a4910cd00a512f1e10503038d710ae4dd4ff19562b4e7fddd5ee7878a939e40f532627226c5572
|
7
|
+
data.tar.gz: aef06d938a3f2c6722c583ad8465ebb7563666c3af6f946061b9197bf5207e41960a377be30e28a3a543fb7e0cdf96c397584594a07087772baa2103a53807af
|
data/CHANGELOG.md
CHANGED
@@ -34,11 +34,41 @@ class LogStash::Outputs::Mongodb < LogStash::Outputs::Base
|
|
34
34
|
# "_id" field in the event.
|
35
35
|
config :generateId, :validate => :boolean, :default => false
|
36
36
|
|
37
|
+
|
38
|
+
# Bulk insert flag, set to true to allow bulk insertion, else it will insert events one by one.
|
39
|
+
config :bulk, :validate => :boolean, :default => false
|
40
|
+
# Bulk interval, Used to insert events periodically if the "bulk" flag is activated.
|
41
|
+
config :bulk_interval, :validate => :number, :default => 2
|
42
|
+
# Bulk events number, if the number of events to insert into a collection raise that limit, it will be bulk inserted
|
43
|
+
# whatever the bulk interval value (mongodb hard limit is 1000).
|
44
|
+
config :bulk_size, :validate => :number, :default => 900, :maximum => 999, :min => 2
|
45
|
+
|
46
|
+
# Mutex used to synchronize access to 'documents'
|
47
|
+
@@mutex = Mutex.new
|
48
|
+
|
37
49
|
public
|
38
50
|
def register
|
39
51
|
Mongo::Logger.logger = @logger
|
40
52
|
conn = Mongo::Client.new(@uri)
|
41
53
|
@db = conn.use(@database)
|
54
|
+
|
55
|
+
if @bulk_size > 1000
|
56
|
+
raise LogStash::ConfigurationError, "Bulk size must be lower than '1000', currently '#{@bulk_size}'"
|
57
|
+
end
|
58
|
+
@documents = {}
|
59
|
+
Thread.new do
|
60
|
+
loop do
|
61
|
+
sleep @bulk_interval
|
62
|
+
@@mutex.synchronize do
|
63
|
+
@documents.each do |collection, values|
|
64
|
+
if values.length > 0
|
65
|
+
@db[collection].insert_many(values)
|
66
|
+
@documents.delete(collection)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
42
72
|
end # def register
|
43
73
|
|
44
74
|
def receive(event)
|
@@ -53,7 +83,23 @@ class LogStash::Outputs::Mongodb < LogStash::Outputs::Base
|
|
53
83
|
if @generateId
|
54
84
|
document["_id"] = BSON::ObjectId.new(nil, event.timestamp)
|
55
85
|
end
|
56
|
-
@
|
86
|
+
if @bulk
|
87
|
+
@@mutex.synchronize do
|
88
|
+
collection = event.sprintf(@collection)
|
89
|
+
if(!@documents[collection])
|
90
|
+
@documents[collection] = []
|
91
|
+
end
|
92
|
+
@documents[collection].push(document)
|
93
|
+
|
94
|
+
if(@documents[collection].length >= @bulk_size)
|
95
|
+
@db[collection].insert_many(@documents[collection])
|
96
|
+
@documents.delete(collection)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
else
|
100
|
+
@db[event.sprintf(@collection)].insert_one(document)
|
101
|
+
end
|
102
|
+
|
57
103
|
rescue => e
|
58
104
|
@logger.warn("Failed to send event to MongoDB", :event => event, :exception => e,
|
59
105
|
:backtrace => e.backtrace)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-mongodb'
|
3
|
-
s.version = '3.0
|
3
|
+
s.version = '3.1.0'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Store events into MongoDB"
|
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/logstash-plugin install gemname. This gem is not a stand-alone program"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-mongodb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|