logstash-output-mongodb-v2 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a1a144cdedb9f97efd6102077aba2773c8ea0b4c
4
+ data.tar.gz: 5962744a903ee4868b05aa6919a70f32d002ff8b
5
+ SHA512:
6
+ metadata.gz: d7fbc76da33d3463e21a638f8a6bdad562d5c3515b41349c199782a912d27ce307cb619316fef9e6059db198b988c4376b39dac99ca77e84288e252d604b7906
7
+ data.tar.gz: 982eb15e5f19eb99d0de5267083c02ffc6b2c477915a97e7c500b2acb2722709530e46ebc29149ee26a11eb678c09a9d6319750b7d3c747bd1ebcbaf2112796c
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ .bundle
4
+ vendor
File without changes
@@ -0,0 +1,21 @@
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
+ * Aaron Mildenstein (untergeek)
6
+ * Graham Bleach (bleach)
7
+ * John E. Vincent (lusis)
8
+ * Jordan Sissel (jordansissel)
9
+ * Kevin Amorin (kamorin)
10
+ * Kevin O'Connor (kjoconnor)
11
+ * Kurt Hurtado (kurtado)
12
+ * Mathias Gug (zimathias)
13
+ * Pete Fritchman (fetep)
14
+ * Pier-Hugues Pellerin (ph)
15
+ * Richard Pijnenburg (electrical)
16
+ * bitsofinfo (bitsofinfo)
17
+
18
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
19
+ Logstash, and you aren't on the list above and want to be, please let us know
20
+ and we'll make sure you're here. Contributions from folks like you are what make
21
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 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.
@@ -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/).
@@ -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-filter-awesome", :path => "/your/local/logstash-filter-awesome"
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 'filter {awesome {}}'
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-filter-awesome.gemspec
71
+ ```
72
+ - Install the plugin from the Logstash home
73
+ ```sh
74
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.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.
@@ -0,0 +1,7 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "logstash/devutils/rake"
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+
5
+
6
+ class LogStash::Outputs::Mongodb < LogStash::Outputs::Base
7
+
8
+ config_name "mongodb"
9
+
10
+ # a MongoDB URI to connect to
11
+ # See http://docs.mongodb.org/manual/reference/connection-string/
12
+ config :endpoints, :validate => :array, :required => true
13
+
14
+ # The database to use
15
+ config :database, :validate => :string, :required => true
16
+
17
+ # The user to authenticate
18
+ config :user, :validate => :string, :required => false
19
+
20
+ # The password of the user to authenticate
21
+ config :password, :validate => :string, :required => false
22
+
23
+ # The collection to use. This value can use `%{foo}` values to dynamically
24
+ # select a collection based on data in the event.
25
+ config :collection, :validate => :string, :required => true
26
+
27
+ # If true, store the @timestamp field in mongodb as an ISODate type instead
28
+ # of an ISO8601 string. For more information about this, see
29
+ # http://www.mongodb.org/display/DOCS/Dates
30
+ config :isodate, :validate => :boolean, :default => false
31
+
32
+ # Number of seconds to wait after failure before retrying
33
+ config :retry_delay, :validate => :number, :default => 3, :required => false
34
+
35
+ # If true, an "_id" field will be added to the document before insertion.
36
+ # The "_id" field will use the timestamp of the event and overwrite an existing
37
+ # "_id" field in the event.
38
+ config :generateId, :validate => :boolean, :default => false
39
+
40
+ public
41
+ def register
42
+ require "mongo"
43
+ options = { database: @database }
44
+ options[:user] = @user unless @user.nil? || @user.empty?
45
+ options[:password] = @password unless @password.nil? || @password.empty?
46
+ @client = Mongo::Client.new(@endpoints, options)
47
+ end # def register
48
+
49
+ public
50
+ def receive(event)
51
+ return unless output?(event)
52
+
53
+ begin
54
+ if @isodate
55
+ # the mongodb driver wants time values as a ruby Time object.
56
+ # set the @timestamp value of the document to a ruby Time object, then.
57
+ document = event.to_hash
58
+ else
59
+ document = event.to_hash.merge("@timestamp" => event["@timestamp"].to_json)
60
+ end
61
+ if @generateId
62
+ document['_id'] = BSON::ObjectId.new(nil, event["@timestamp"])
63
+ end
64
+ @client[event.sprintf(@collection)].insert_one(document)
65
+ rescue Mongo::Error => e
66
+ @logger.warn("Failed to send event to MongoDB", :event => event, :exception => e,
67
+ :backtrace => e.backtrace)
68
+ sleep @retry_delay
69
+ retry
70
+ end
71
+ end # def receive
72
+ end # class LogStash::Outputs::Mongodb
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-output-mongodb-v2'
4
+ s.version = '0.2.2'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "Store events into MongoDB"
7
+ s.description = "This gem is a fork of the logstash plugin (https://github.com/logstash-plugins/logstash-output-elasticsearch) built for the updated mongo v2 sdk. It is 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"
8
+ s.authors = ["Elastic", "Noah Blumenthal"]
9
+ s.email = 'info@elastic.co'
10
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
24
+
25
+ s.add_runtime_dependency 'mongo', '~>2.0'
26
+
27
+ s.add_development_dependency 'logstash-devutils'
28
+ end
29
+
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-mongodb-v2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Elastic
8
+ - Noah Blumenthal
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-07-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: logstash-core
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 1.4.0
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.0
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: 1.4.0
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0
34
+ - !ruby/object:Gem::Dependency
35
+ name: mongo
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: logstash-devutils
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: This gem is a fork of the logstash plugin (https://github.com/logstash-plugins/logstash-output-elasticsearch)
63
+ built for the updated mongo v2 sdk. It is required to be installed on top of the
64
+ Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
65
+ a stand-alone program
66
+ email: info@elastic.co
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - ".gitignore"
72
+ - CHANGELOG.md
73
+ - CONTRIBUTORS
74
+ - Gemfile
75
+ - LICENSE
76
+ - NOTICE.TXT
77
+ - README.md
78
+ - Rakefile
79
+ - lib/logstash/outputs/mongodb.rb
80
+ - logstash-output-mongodb.gemspec
81
+ - spec/outputs/mongodb_spec.rb
82
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
83
+ licenses:
84
+ - Apache License (2.0)
85
+ metadata:
86
+ logstash_plugin: 'true'
87
+ logstash_group: output
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.2.0
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Store events into MongoDB
108
+ test_files:
109
+ - spec/outputs/mongodb_spec.rb