logstash-output-arangodb 0.1.0

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: 508bccdaeeaf41916a528f694aed33127552909d
4
+ data.tar.gz: 6a719bd0052135c8719ea18001bb618f37650c72
5
+ SHA512:
6
+ metadata.gz: 1d021020e77841b36eb22a51abcffd4a1cc6a4db8a64bd7fdedae83719c0f7a8e65110aa0bad5973fe652228c2b561a7e91a861c22348942a621833b55e842c2
7
+ data.tar.gz: 11ea4efea0fab786ef80bfa8d71b6d56fcb6301521825f65c3178c7f98e9149d106581c09f4a5e007a372ee94b4f77cbc88e6cc2c6ebf456d9d6d114ed52b840
@@ -0,0 +1,36 @@
1
+ *.lock
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
@@ -0,0 +1,9 @@
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
+
6
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
7
+ Logstash, and you aren't on the list above and want to be, please let us know
8
+ and we'll make sure you're here. Contributions from folks like you are what make
9
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
@@ -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 logstash-users@googlegroups.com mailing list.
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,23 @@
1
+ ROOT = File.expand_path(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift File.join(ROOT, 'lib')
3
+ Dir.glob('lib/**').each{ |d| $LOAD_PATH.unshift(File.join(ROOT, d)) }
4
+
5
+ require 'rubygems'
6
+ require 'bundler'
7
+ begin
8
+ Bundler.setup(:default, :development)
9
+ rescue Bundler::BundlerError => e
10
+ $stderr.puts e.message
11
+ $stderr.puts "Run `bundle install` to install missing gems"
12
+ exit e.status_code
13
+ end
14
+
15
+ require 'bundler/gem_tasks'
16
+ require 'rspec'
17
+ require 'rspec/core/rake_task'
18
+
19
+ desc "Specs all at ones."
20
+ RSpec::Core::RakeTask.new(:spec) do |t|
21
+ t.fail_on_error = true
22
+ t.verbose = false
23
+ end
@@ -0,0 +1,86 @@
1
+ require "logstash/namespace"
2
+ require "logstash/outputs/base"
3
+ require "ashikawa-core"
4
+ require "stud/buffer"
5
+
6
+ class LogStash::Outputs::ArangoDB < LogStash::Outputs::Base
7
+
8
+ include Stud::Buffer
9
+
10
+ config_name 'arangodb'
11
+
12
+ # The URL used to connect to the database.
13
+ config :url, :validate => :string, :default => "http://localhost:8529"
14
+
15
+ # The database that is going to be used
16
+ config :database, :validate => :string, :default => "logstash"
17
+
18
+ # The username used when authenticating with ArangoDB
19
+ config :username, :validate => :string, :required => true
20
+
21
+ # The password used when authenticating with ArangoDB
22
+ config :password, :validate => :password, :required => true
23
+
24
+ # The collection used to log the events, by default it will create a collection
25
+ # per day of logs following the pattern logstash-%{+YYYY-MM-dd}
26
+ config :collection, :validate => :string, :default => "logstash-%{+YYYY-MM-dd}"
27
+
28
+ # This plugin uses the bulk index api for improved indexing performance.
29
+ # To make efficient bulk api calls, we will buffer a certain number of
30
+ # events before flushing that out to ArangoDB. This setting
31
+ # controls how many events will be buffered before sending a batch
32
+ # of events.
33
+ config :flush_size, :validate => :number, :default => 500
34
+
35
+ # The amount of time since last flush before a flush is forced.
36
+ #
37
+ # This setting helps ensure slow event rates don't get stuck in Logstash.
38
+ # For example, if your `flush_size` is 100, and you have received 10 events,
39
+ # and it has been more than `idle_flush_time` seconds since the last flush,
40
+ # Logstash will flush those 10 events automatically.
41
+ #
42
+ # This helps keep both fast and slow log streams moving along in
43
+ # near-real-time.
44
+ config :idle_flush_time, :validate => :number, :default => 1
45
+
46
+ def register
47
+
48
+ @host = Socket.gethostname.force_encoding(Encoding::UTF_8)
49
+
50
+ @database = Ashikawa::Core::Database.new do |config|
51
+ config.url = @url
52
+ config.database_name = @database if @database
53
+ config.username = @username
54
+ config.password = @password.value
55
+ end
56
+
57
+ buffer_initialize(
58
+ :max_items => @flush_size,
59
+ :max_interval => @idle_flush_time,
60
+ :logger => @logger
61
+ )
62
+
63
+ end
64
+
65
+ def receive(event)
66
+ return unless output?(event)
67
+ buffer_receive(event, :server => @host)
68
+ end
69
+
70
+ def teardown
71
+ buffer_flush(:final => true)
72
+ end
73
+
74
+ def flush(events, params, final=false)
75
+ events.each do |event|
76
+ collection(event).create_document(event.to_hash)
77
+ end
78
+ end
79
+
80
+ private
81
+
82
+ def collection(event)
83
+ @database[event.sprintf(@collection)]
84
+ end
85
+
86
+ end
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-output-arangodb'
4
+ s.version = '0.1.0'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "Logstash Output to ArangoDB"
7
+ s.description = "Output events to ArangoDB"
8
+ s.authors = ["Pere Urbon-Bayes"]
9
+ s.email = 'pere.urbon@gmail.com'
10
+ s.homepage = "http://purbon.com/"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = `git ls-files`.split($\)
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
+ s.add_runtime_dependency 'logstash-core', '>= 1.4.0', '< 2.0.0'
23
+ s.add_runtime_dependency 'ashikawa-core', '~> 0.14.0'
24
+ s.add_runtime_dependency 'stud', ['>= 0.0.17', '~> 0.0']
25
+
26
+ s.add_development_dependency 'logstash-devutils'
27
+ s.add_development_dependency 'logstash-codec-plain'
28
+
29
+ end
@@ -0,0 +1,42 @@
1
+ require_relative '../spec_helper'
2
+ require "logstash/plugin"
3
+ require "logstash/json"
4
+
5
+ describe LogStash::Outputs::ArangoDB do
6
+
7
+ let(:config) do
8
+ { "username" => "logstash", "password" => "logstash" }
9
+ end
10
+
11
+ describe "registration" do
12
+
13
+ let(:output) { LogStash::Plugin.lookup("output", "arangodb").new(config) }
14
+
15
+ it "should register" do
16
+ expect { output.register }.to_not raise_error
17
+ end
18
+
19
+ it "should teardown" do
20
+ output.register
21
+ expect { output.teardown }.to_not raise_error
22
+ end
23
+ end
24
+
25
+ describe "#save" do
26
+
27
+ subject { LogStash::Outputs::ArangoDB.new(config) }
28
+ let(:event) { LogStash::Event.new({"message" => "dummy"}) }
29
+
30
+ before(:each) do
31
+ subject.register
32
+ end
33
+
34
+
35
+ it "should buffer the event to be flushed" do
36
+ expect(subject).to receive(:buffer_receive)
37
+ subject.receive(event)
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,2 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/outputs/arangodb"
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-arangodb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pere Urbon-Bayes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
+ dependencies:
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
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 1.4.0
28
+ - - <
29
+ - !ruby/object:Gem::Version
30
+ version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
+ - !ruby/object:Gem::Dependency
34
+ name: ashikawa-core
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: 0.14.0
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 0.14.0
45
+ prerelease: false
46
+ type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: stud
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.17
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: '0.0'
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.17
62
+ - - ~>
63
+ - !ruby/object:Gem::Version
64
+ version: '0.0'
65
+ prerelease: false
66
+ type: :runtime
67
+ - !ruby/object:Gem::Dependency
68
+ name: logstash-devutils
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirement: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ prerelease: false
80
+ type: :development
81
+ - !ruby/object:Gem::Dependency
82
+ name: logstash-codec-plain
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ prerelease: false
94
+ type: :development
95
+ description: Output events to ArangoDB
96
+ email: pere.urbon@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - CONTRIBUTORS
103
+ - Gemfile
104
+ - LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - lib/logstash/outputs/arangodb.rb
108
+ - logstash-output-arangodb.gemspec
109
+ - spec/outputs/arangodb_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: http://purbon.com/
112
+ licenses:
113
+ - Apache License (2.0)
114
+ metadata:
115
+ logstash_plugin: 'true'
116
+ logstash_group: output
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.4.6
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Logstash Output to ArangoDB
137
+ test_files:
138
+ - spec/outputs/arangodb_spec.rb
139
+ - spec/spec_helper.rb