logstash-output-mongo 1.0.0

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
+ SHA256:
3
+ metadata.gz: 693ff9cebf563deaab2dac0204c7593c277c5e15e690bce558bb0f6ef6744f60
4
+ data.tar.gz: 78ffa0f1ea7138aac9c19a006009ef100b8477711c48b6483d78c27058489841
5
+ SHA512:
6
+ metadata.gz: 6b21aa3abc1e982a2cca563231d54fbd64528951add21d5296323e08cb605ef17a425a3665321fd41dacec20fb65458ef1438c35c8e66f9ab7920958c33c853c
7
+ data.tar.gz: bfddcf617146171fb29b267260108f3cea44f32595aff2e918e12a17b8d49f3cea8cf74d782707654b0b8e01658d2f12c3c2faa53a2e96beb076b74ad5c4717a
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 1.0.0
2
+ - Basic integration for
3
+ - insert
4
+ - update
5
+ - upsert
6
+ - delete
data/CONTRIBUTORS ADDED
@@ -0,0 +1,10 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Diego Herrera (lancha90)
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012-2018 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.
data/NOTICE.TXT ADDED
@@ -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/).
data/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # Logstash Plugin
2
+
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-output-mongodb.svg)](https://travis-ci.org/logstash-plugins/logstash-output-mongodb)
4
+
5
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
+
7
+ 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.
8
+
9
+ ## Documentation
10
+
11
+ 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/).
12
+
13
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
14
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
15
+
16
+ ## Need Help?
17
+
18
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
19
+
20
+ ## Developing
21
+
22
+ ### 1. Plugin Developement and Testing
23
+
24
+ #### Code
25
+ - To get started, you'll need JRuby with the Bundler gem installed.
26
+
27
+ - 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).
28
+
29
+ - Install dependencies
30
+ ```sh
31
+ bundle install
32
+ ```
33
+
34
+ #### Test
35
+
36
+ - Update your dependencies
37
+
38
+ ```sh
39
+ bundle install
40
+ ```
41
+
42
+ - Run tests
43
+
44
+ ```sh
45
+ bundle exec rspec
46
+ ```
47
+
48
+ ### 2. Running your unpublished Plugin in Logstash
49
+
50
+ #### 2.1 Run in a local Logstash clone
51
+
52
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
53
+ ```ruby
54
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
55
+ ```
56
+ - Install plugin
57
+ ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
62
+ bin/plugin install --no-verify
63
+
64
+ ```
65
+ - Run Logstash with your plugin
66
+ ```sh
67
+ bin/logstash -e 'filter {awesome {}}'
68
+ ```
69
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
70
+
71
+ #### 2.2 Run in an installed Logstash
72
+
73
+ 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:
74
+
75
+ - Build your plugin gem
76
+ ```sh
77
+ gem build logstash-filter-awesome.gemspec
78
+ ```
79
+ - Install the plugin from the Logstash home
80
+ ```sh
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
87
+ ```
88
+ - Start Logstash and proceed to test the plugin
89
+
90
+ ## Contributing
91
+
92
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
93
+
94
+ 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.
95
+
96
+ It is more important to the community that you are able to contribute.
97
+
98
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,137 @@
1
+ :plugin: mongodb
2
+ :type: output
3
+ :default_codec: plain
4
+
5
+ ///////////////////////////////////////////
6
+ START - GENERATED VARIABLES, DO NOT EDIT!
7
+ ///////////////////////////////////////////
8
+ :version: %VERSION%
9
+ :release_date: %RELEASE_DATE%
10
+ :changelog_url: %CHANGELOG_URL%
11
+ :include_path: ../../../../logstash/docs/include
12
+ ///////////////////////////////////////////
13
+ END - GENERATED VARIABLES, DO NOT EDIT!
14
+ ///////////////////////////////////////////
15
+
16
+ [id="plugins-{type}s-{plugin}"]
17
+
18
+ === Mongodb output plugin
19
+
20
+ include::{include_path}/plugin_header.asciidoc[]
21
+
22
+ ==== Description
23
+
24
+ This output writes events to MongoDB.
25
+
26
+ [id="plugins-{type}s-{plugin}-options"]
27
+ ==== Mongodb Output Configuration Options
28
+
29
+ This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
30
+
31
+ [cols="<,<,<",options="header",]
32
+ |=======================================================================
33
+ |Setting |Input type|Required
34
+ | <<plugins-{type}s-{plugin}-bulk>> |<<boolean,boolean>>|No
35
+ | <<plugins-{type}s-{plugin}-bulk_interval>> |<<number,number>>|No
36
+ | <<plugins-{type}s-{plugin}-bulk_size>> |<<number,number>>|No
37
+ | <<plugins-{type}s-{plugin}-collection>> |<<string,string>>|Yes
38
+ | <<plugins-{type}s-{plugin}-database>> |<<string,string>>|Yes
39
+ | <<plugins-{type}s-{plugin}-generateId>> |<<boolean,boolean>>|No
40
+ | <<plugins-{type}s-{plugin}-isodate>> |<<boolean,boolean>>|No
41
+ | <<plugins-{type}s-{plugin}-retry_delay>> |<<number,number>>|No
42
+ | <<plugins-{type}s-{plugin}-uri>> |<<string,string>>|Yes
43
+ |=======================================================================
44
+
45
+ Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
46
+ output plugins.
47
+
48
+ &nbsp;
49
+
50
+ [id="plugins-{type}s-{plugin}-bulk"]
51
+ ===== `bulk`
52
+
53
+ * Value type is <<boolean,boolean>>
54
+ * Default value is `false`
55
+
56
+ Bulk insert flag, set to true to allow bulk insertion, else it will insert events one by one.
57
+
58
+ [id="plugins-{type}s-{plugin}-bulk_interval"]
59
+ ===== `bulk_interval`
60
+
61
+ * Value type is <<number,number>>
62
+ * Default value is `2`
63
+
64
+ Bulk interval, Used to insert events periodically if the "bulk" flag is activated.
65
+
66
+ [id="plugins-{type}s-{plugin}-bulk_size"]
67
+ ===== `bulk_size`
68
+
69
+ * Value type is <<number,number>>
70
+ * Default value is `900`
71
+
72
+ Bulk events number, if the number of events to insert into a collection raise that limit, it will be bulk inserted
73
+ whatever the bulk interval value (mongodb hard limit is 1000).
74
+
75
+ [id="plugins-{type}s-{plugin}-collection"]
76
+ ===== `collection`
77
+
78
+ * This is a required setting.
79
+ * Value type is <<string,string>>
80
+ * There is no default value for this setting.
81
+
82
+ The collection to use. This value can use `%{foo}` values to dynamically
83
+ select a collection based on data in the event.
84
+
85
+ [id="plugins-{type}s-{plugin}-database"]
86
+ ===== `database`
87
+
88
+ * This is a required setting.
89
+ * Value type is <<string,string>>
90
+ * There is no default value for this setting.
91
+
92
+ The database to use.
93
+
94
+ [id="plugins-{type}s-{plugin}-generateId"]
95
+ ===== `generateId`
96
+
97
+ * Value type is <<boolean,boolean>>
98
+ * Default value is `false`
99
+
100
+ If true, an "_id" field will be added to the document before insertion.
101
+ The "_id" field will use the timestamp of the event and overwrite an existing
102
+ "_id" field in the event.
103
+
104
+ [id="plugins-{type}s-{plugin}-isodate"]
105
+ ===== `isodate`
106
+
107
+ * Value type is <<boolean,boolean>>
108
+ * Default value is `false`
109
+
110
+ If true, store the @timestamp field in MongoDB as an ISODate type instead
111
+ of an ISO8601 string. For more information about this, see
112
+ http://www.mongodb.org/display/DOCS/Dates.
113
+
114
+ [id="plugins-{type}s-{plugin}-retry_delay"]
115
+ ===== `retry_delay`
116
+
117
+ * Value type is <<number,number>>
118
+ * Default value is `3`
119
+
120
+ The number of seconds to wait after failure before retrying.
121
+
122
+ [id="plugins-{type}s-{plugin}-uri"]
123
+ ===== `uri`
124
+
125
+ * This is a required setting.
126
+ * Value type is <<string,string>>
127
+ * There is no default value for this setting.
128
+
129
+ A MongoDB URI to connect to.
130
+ See http://docs.mongodb.org/manual/reference/connection-string/.
131
+
132
+
133
+
134
+ [id="plugins-{type}s-{plugin}-common-options"]
135
+ include::{include_path}/{type}.asciidoc[]
136
+
137
+ :default_codec!:
@@ -0,0 +1,66 @@
1
+ # Copyright (C) 2009-2014 MongoDB Inc.
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.
14
+
15
+ # Modified 2015 Elastic
16
+
17
+ module BSON
18
+
19
+ # Injects behaviour for encoding and decoding BigDecimal values
20
+ # to and from # raw bytes as specified by the BSON spec.
21
+ #
22
+ # @see http://bsonspec.org/#/specification
23
+ module BigDecimal
24
+
25
+ # A floating point is type 0x01 in the BSON spec.
26
+ BSON_TYPE = 1.chr.force_encoding(BINARY).freeze
27
+
28
+ # The pack directive is for 8 byte floating points.
29
+ PACK = "E".freeze
30
+
31
+ # Get the floating point as encoded BSON.
32
+ # @example Get the floating point as encoded BSON.
33
+ # 1.221311.to_bson
34
+ # @return [ String ] The encoded string.
35
+ # @see http://bsonspec.org/#/specification
36
+ def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
37
+ buffer.put_bytes([ self ].pack(PACK))
38
+ end
39
+
40
+ module ClassMethods
41
+
42
+ # Deserialize an instance of a BigDecimal from a BSON double.
43
+ # @param [ BSON ] bson object from Mongo.
44
+ # @return [ BigDecimal ] The decoded BigDecimal.
45
+ # @see http://bsonspec.org/#/specification
46
+ def from_bson(bson)
47
+ from_bson_double(bson.get_bytes(8))
48
+ end
49
+
50
+ private
51
+
52
+ def from_bson_double(double)
53
+ new(double.unpack(PACK).first.to_s)
54
+ end
55
+ end
56
+
57
+ # Register this type when the module is loaded.
58
+ Registry.register(BSON_TYPE, ::BigDecimal)
59
+ end
60
+
61
+ # Enrich the core BigDecimal class with this module.
62
+ #
63
+ # @since 2.0.0
64
+ ::BigDecimal.send(:include, BigDecimal)
65
+ ::BigDecimal.send(:extend, BigDecimal::ClassMethods)
66
+ end
@@ -0,0 +1,76 @@
1
+ # Copyright (C) 2009-2014 MongoDB Inc.
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.
14
+
15
+ # Modified 2015 Elastic
16
+
17
+ module BSON
18
+
19
+ # Injects behaviour for encoding and decoding time values to
20
+ # and from raw bytes as specified by the BSON spec.
21
+ #
22
+ # @see http://bsonspec.org/#/specification
23
+ module LogStashEvent
24
+
25
+ # An Event is an embedded document is type 0x03 in the BSON spec..
26
+ BSON_TYPE = 3.chr.force_encoding(BINARY).freeze
27
+
28
+ # Get the event as encoded BSON.
29
+ # @example Get the hash as encoded BSON.
30
+ # Event.new("field" => "value").to_bson
31
+ # @return [ String ] The encoded string.
32
+ # @see http://bsonspec.org/#/specification
33
+ def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
34
+ position = buffer.length
35
+ buffer.put_int32(0)
36
+ to_hash.each do |field, value|
37
+ buffer.put_byte(value.bson_type)
38
+ buffer.put_cstring(field.to_bson_key)
39
+ value.to_bson(buffer)
40
+ end
41
+ buffer.put_byte(NULL_BYTE)
42
+ buffer.replace_int32(position, buffer.length - position)
43
+ end
44
+
45
+ # Converts the event to a normalized value in a BSON document.
46
+ # @example Convert the event to a normalized value.
47
+ # event.to_bson_normalized_value
48
+ # @return [ BSON::Document ] The normalized event.
49
+ def to_bson_normalized_value
50
+ Document.new(self)
51
+ end
52
+
53
+ module ClassMethods
54
+ # Deserialize the Event from BSON.
55
+ # @param [ ByteBuffer ] buffer The byte buffer.
56
+ # @return [ Event ] The decoded bson document.
57
+ # @see http://bsonspec.org/#/specification
58
+ def from_bson(buffer)
59
+ hash = Hash.new
60
+ buffer.get_int32 # Throw away the size.
61
+ while (type = buffer.get_byte) != NULL_BYTE
62
+ field = buffer.get_cstring
63
+ hash.store(field, BSON::Registry.get(type).from_bson(buffer))
64
+ end
65
+ new(hash)
66
+ end
67
+ end
68
+
69
+ # Register this type when the module is loaded.
70
+ Registry.register(BSON_TYPE, ::LogStash::Event)
71
+ end
72
+
73
+ # Enrich the core LogStash::Event class with this module.
74
+ ::LogStash::Event.send(:include, ::LogStashEvent)
75
+ ::LogStash::Event.send(:extend, ::LogStashEvent::ClassMethods)
76
+ end
@@ -0,0 +1,50 @@
1
+ # Copyright (C) 2009-2014 MongoDB Inc.
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.
14
+
15
+ # Modified 2015 Elastic
16
+
17
+ module BSON
18
+
19
+ # Injects behaviour for encoding and decoding time values to
20
+ # and from raw bytes as specified by the BSON spec.
21
+ #
22
+ # @see http://bsonspec.org/#/specification
23
+ module LogStashTimestamp
24
+
25
+ # A time is type 0x09 in the BSON spec.
26
+ BSON_TYPE = 9.chr.force_encoding(BINARY).freeze
27
+
28
+ def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
29
+ time.to_bson(buffer)
30
+ end
31
+
32
+ module ClassMethods
33
+ # Deserialize UTC time from BSON.
34
+ # @param [ BSON ] bson encoded time.
35
+ # @return [ ::LogStash::Timestamp ] The decoded UTC time as a ::LogStash::Timestamp.
36
+ # @see http://bsonspec.org/#/specification
37
+ def from_bson(bson)
38
+ seconds, fragment = BSON::Int64.from_bson(bson).divmod(1000)
39
+ new(::Time.at(seconds, fragment * 1000).utc)
40
+ end
41
+ end
42
+
43
+ # Register this type when the module is loaded.
44
+ Registry.register(BSON_TYPE, ::LogStash::Timestamp)
45
+ end
46
+
47
+ # Enrich the core LogStash::Timestamp class with this module.
48
+ ::LogStash::Timestamp.send(:include, LogStashTimestamp)
49
+ ::LogStash::Timestamp.send(:extend, LogStashTimestamp::ClassMethods)
50
+ end
@@ -0,0 +1,116 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+ require "mongo"
5
+ require_relative "bson/big_decimal"
6
+ require_relative "bson/logstash_timestamp"
7
+
8
+ # This output writes events to MongoDB.
9
+ class LogStash::Outputs::Mongo < LogStash::Outputs::Base
10
+
11
+ config_name "mongo"
12
+
13
+ # A MongoDB URI to connect to.
14
+ # See http://docs.mongodb.org/manual/reference/connection-string/.
15
+ config :uri, :validate => :string, :required => true
16
+
17
+ # The database to use.
18
+ config :database, :validate => :string, :required => true
19
+
20
+ # The collection to use. This value can use `%{foo}` values to dynamically
21
+ # select a collection based on data in the event.
22
+ config :collection, :validate => :string, :required => true
23
+
24
+ # If true, store the @timestamp field in MongoDB as an ISODate type instead
25
+ # of an ISO8601 string. For more information about this, see
26
+ # http://www.mongodb.org/display/DOCS/Dates.
27
+ config :isodate, :validate => :boolean, :default => false
28
+
29
+ # The number of seconds to wait after failure before retrying.
30
+ config :retry_delay, :validate => :number, :default => 3, :required => false
31
+
32
+ # Statement, define the statement to be run. Default `insert`
33
+ config :type, :validate => :string, :default => "insert"
34
+
35
+ # Statement, define the statement to be run. If is null insert_one
36
+ config :attributes, :validate => :array, :default => []
37
+
38
+ # Mutex used to synchronize access to 'documents'
39
+ @@mutex = Mutex.new
40
+
41
+ def register
42
+
43
+ Mongo::Logger.logger = @logger
44
+ conn = Mongo::Client.new(@uri)
45
+ @db = conn.use(@database)
46
+
47
+ @closed = Concurrent::AtomicBoolean.new(false)
48
+ end
49
+
50
+ def receive(event)
51
+ begin
52
+ # Our timestamp object now has a to_bson method, using it here
53
+ # {}.merge(other) so we don't taint the event hash innards
54
+ document = {}.merge(event.to_hash)
55
+
56
+ @logger.info("Type=[#{@type}] Collection=[#{@collection}] _id=[#{document["_id"]}]")
57
+
58
+ case @type
59
+
60
+ when "upsert"
61
+ statement = buildStatement(document)
62
+
63
+ @db[event.sprintf(@collection)].update_one(
64
+ { '_id' => document["_id"]},
65
+ { '$set' => statement},
66
+ :upsert => true
67
+ )
68
+
69
+ when "update"
70
+ statement = buildStatement(document)
71
+
72
+ @db[event.sprintf(@collection)].update_one(
73
+ { '_id' => document["_id"]},
74
+ { '$set' => statement}
75
+ )
76
+
77
+ when "insert"
78
+ @db[event.sprintf(@collection)].insert_one(document)
79
+
80
+ when "delete"
81
+ @db[event.sprintf(@collection)].delete_one({ '_id' => document["_id"]})
82
+
83
+ end
84
+
85
+ rescue => e
86
+ if e.message =~ /^E11000/
87
+ # On a duplicate key error, skip the insert.
88
+ # We could check if the duplicate key err is the _id key
89
+ # and generate a new primary key.
90
+ # If the duplicate key error is on another field, we have no way
91
+ # to fix the issue.
92
+ @logger.warn("Skipping insert because of a duplicate key error", :event => event, :exception => e)
93
+ else
94
+ @logger.warn("Failed to send event to MongoDB, retrying in #{@retry_delay.to_s} seconds", :event => event, :exception => e)
95
+ sleep(@retry_delay)
96
+ retry
97
+ end
98
+ end
99
+ end
100
+
101
+ def buildStatement(document)
102
+
103
+ statement = {}
104
+
105
+ @attributes.each do |attr|
106
+ statement[attr] = document[attr]
107
+ end
108
+
109
+ return statement
110
+
111
+ end
112
+
113
+ def close
114
+ @closed.make_true
115
+ end
116
+ end
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-mongo'
3
+ s.version = '1.0.0'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "Writes events to MongoDB (insert, update, upsert & delete)"
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"
7
+ s.authors = ["Elastic", "@lancha90"]
8
+ s.email = 'diegomao627@gmail.com'
9
+ s.homepage = "https://github.com/lancha90/logstash-output-mongo"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir["lib/**/*","spec/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"]
14
+
15
+ # Tests
16
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
17
+
18
+ # Special flag to let us know this is actually a logstash plugin
19
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
20
+
21
+ # Gem dependencies
22
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
23
+ s.add_runtime_dependency 'logstash-codec-plain'
24
+ s.add_runtime_dependency 'mongo', '~> 2.6'
25
+ s.add_runtime_dependency 'bson', '4.7.0'
26
+
27
+ s.add_development_dependency 'logstash-devutils'
28
+ end
29
+
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-mongo
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Elastic
8
+ - "@lancha90"
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2022-05-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.60'
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: '2.99'
23
+ name: logstash-core-plugin-api
24
+ prerelease: false
25
+ type: :runtime
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '1.60'
31
+ - - "<="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.99'
34
+ - !ruby/object:Gem::Dependency
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ name: logstash-codec-plain
41
+ prerelease: false
42
+ type: :runtime
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.6'
54
+ name: mongo
55
+ prerelease: false
56
+ type: :runtime
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.6'
62
+ - !ruby/object:Gem::Dependency
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '='
66
+ - !ruby/object:Gem::Version
67
+ version: 4.7.0
68
+ name: bson
69
+ prerelease: false
70
+ type: :runtime
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 4.7.0
76
+ - !ruby/object:Gem::Dependency
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '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'
90
+ description: This gem is a Logstash plugin required to be installed on top of the
91
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
92
+ gem is not a stand-alone program
93
+ email: diegomao627@gmail.com
94
+ executables: []
95
+ extensions: []
96
+ extra_rdoc_files: []
97
+ files:
98
+ - CHANGELOG.md
99
+ - CONTRIBUTORS
100
+ - Gemfile
101
+ - LICENSE
102
+ - NOTICE.TXT
103
+ - README.md
104
+ - docs/index.asciidoc
105
+ - lib/logstash/outputs/bson/big_decimal.rb
106
+ - lib/logstash/outputs/bson/logstash_event.rb
107
+ - lib/logstash/outputs/bson/logstash_timestamp.rb
108
+ - lib/logstash/outputs/mongo.rb
109
+ - logstash-output-mongo.gemspec
110
+ homepage: https://github.com/lancha90/logstash-output-mongo
111
+ licenses:
112
+ - Apache License (2.0)
113
+ metadata:
114
+ logstash_plugin: 'true'
115
+ logstash_group: output
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubygems_version: 3.2.3
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Writes events to MongoDB (insert, update, upsert & delete)
135
+ test_files: []