logstash-output-rollbar 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: 9cf8468bace9cd1033e04afad90ec751ef2a5fd9
4
+ data.tar.gz: c8803907ca47529591091682e3f544f33f20f6db
5
+ SHA512:
6
+ metadata.gz: 699c35e6491161c93650e7701c20525b9a116c1eaef4cc1ccfbaf901d578d126593b7fdfb67d02eca1e74837eaaf8373060a15de9e7bce144d928903c055bb3a
7
+ data.tar.gz: 49d8f644c1eae5a88652c245964a0581b7dc7de39712cc7d3996027dbd9cd4b66aa013b1625fd9bde1b5a38b75b866cf73fa1c55969715775ffe570ec0c09832
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ .bundle
4
+ vendor
@@ -0,0 +1,15 @@
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
+ * Colin Surprenant (colinsurprenant)
6
+ * John E. Vincent (lusis)
7
+ * Jordan Sissel (jordansissel)
8
+ * Kurt Hurtado (kurtado)
9
+ * Pier-Hugues Pellerin (ph)
10
+ * Richard Pijnenburg (electrical)
11
+
12
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
13
+ Logstash, and you aren't on the list above and want to be, please let us know
14
+ and we'll make sure you're here. Contributions from folks like you are what make
15
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012-2015 Elasticsearch <http://www.elasticsearch.org>
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,95 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash) that sends events to the [Rollbar](https://www.rollbar.com) error monitoring service.
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.
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ ```sh
35
+ bundle exec rspec
36
+ ```
37
+
38
+ The Logstash code required to run the tests/specs is specified in the `Gemfile` by the line similar to:
39
+ ```ruby
40
+ gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
41
+ ```
42
+ To test against another version or a local Logstash, edit the `Gemfile` to specify an alternative location, for example:
43
+ ```ruby
44
+ gem "logstash", :github => "elasticsearch/logstash", :ref => "master"
45
+ ```
46
+ ```ruby
47
+ gem "logstash", :path => "/your/local/logstash"
48
+ ```
49
+
50
+ Then update your dependencies and run your tests:
51
+
52
+ ```sh
53
+ bundle install
54
+ bundle exec rspec
55
+ ```
56
+
57
+ ### 2. Running your unpublished Plugin in Logstash
58
+
59
+ #### 2.1 Run in a local Logstash clone
60
+
61
+ - Edit Logstash `tools/Gemfile` and add the local plugin path, for example:
62
+ ```ruby
63
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
64
+ ```
65
+ - Update Logstash dependencies
66
+ ```sh
67
+ rake vendor:gems
68
+ ```
69
+ - Run Logstash with your plugin
70
+ ```sh
71
+ bin/logstash -e 'filter {awesome {}}'
72
+ ```
73
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
74
+
75
+ #### 2.2 Run in an installed Logstash
76
+
77
+ - Build your plugin gem
78
+ ```sh
79
+ gem build logstash-filter-awesome.gemspec
80
+ ```
81
+ - Install the plugin from the Logstash home
82
+ ```sh
83
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
84
+ ```
85
+ - Start Logstash and proceed to test the plugin
86
+
87
+ ## Contributing
88
+
89
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
90
+
91
+ 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.
92
+
93
+ It is more important to me that you are able to contribute.
94
+
95
+ 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,93 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+ require "json"
5
+
6
+ # The Rollbar output will send events to the Rollbar event monitoring service.
7
+ # The only required field is a Rollbar project access token with post_server_item
8
+ # permissions. If you're already using Rollbar to report errors directly from your
9
+ # applications, you can use the same token.
10
+ class LogStash::Outputs::Rollbar < LogStash::Outputs::Base
11
+ config_name "rollbar"
12
+ milestone 1
13
+
14
+ # Your Rollbar access token
15
+ config :access_token, :validate => :string, :required => true
16
+
17
+ # The Rollbar environment
18
+ config :environment, :validate => :string, :default => 'production'
19
+
20
+ # The Rollbar event level (info, warning, error)
21
+ config :level, :validate => ['debug', 'info', 'warning', 'error', 'critical'] , :default => 'info'
22
+
23
+ # Format for the Rollbar "message" or item title. In most cases you'll want to override this
24
+ # and build up a message with specific fields from the event.
25
+ config :format, :validate => :string, :default => "%{message}"
26
+
27
+ # Rollbar API URL endpoint. You shouldn't need to change this.
28
+ config :endpoint, :validate => :string, :default => 'https://api.rollbar.com/api/1/item/'
29
+
30
+ def hash_recursive
31
+ Hash.new do |hash, key|
32
+ hash[key] = hash_recursive
33
+ end
34
+ end
35
+
36
+ public
37
+ def register
38
+ require 'net/https'
39
+ require 'uri'
40
+ @rb_uri = URI.parse(@endpoint)
41
+ @client = Net::HTTP.new(@rb_uri.host, @rb_uri.port)
42
+ if @rb_uri.scheme == "https"
43
+ @client.use_ssl = true
44
+ @client.verify_mode = OpenSSL::SSL::VERIFY_NONE
45
+ end
46
+ end # def register
47
+
48
+ public
49
+ def receive(event)
50
+ return unless output?(event)
51
+
52
+ rb_item = hash_recursive
53
+ rb_item['access_token'] = @access_token
54
+
55
+ data = event.to_hash
56
+
57
+ #
58
+ # If logstash has created 'rollbar' fields, we'll use those to populate the item...
59
+ #
60
+ if data['rollbar']
61
+ merge_keys = %w{platform language framework context request person server client fingerprint title uuid}
62
+ merge_keys.each do |key|
63
+ data['rollbar'][key] && rb_item['data'][key] = data['rollbar'][key]
64
+ end
65
+ data.delete('rollbar')
66
+ end
67
+
68
+ # ...then put whatever's left in 'custom'...
69
+ rb_item['data']['body']['custom'] = data
70
+
71
+ # ...and finally override the top level fields that have a specific meaning
72
+ rb_item['data']['timestamp'] = event.timestamp.to_i
73
+ rb_item['data']['level'] = @level
74
+ rb_item['data']['environment'] = @environment
75
+ rb_item['data']['body']['message']['body'] = event.sprintf(@format)
76
+
77
+ rb_item['data']['notifier']['name'] = 'logstash'
78
+ rb_item['data']['notifier']['version'] = '0.1.0'
79
+
80
+ @logger.debug("Rollbar Item", :rb_item => rb_item)
81
+
82
+ begin
83
+ request = Net::HTTP::Post.new(@rb_uri.path)
84
+ request.body = JSON.dump(rb_item)
85
+ @logger.debug("Rollbar Request", :request => request.body)
86
+ response = @client.request(request)
87
+ @logger.debug("Rollbar Response", :response => response.body)
88
+
89
+ rescue Exception => e
90
+ @logger.warn("Rollbar Exception", :rb_error => e.backtrace)
91
+ end
92
+ end # def receive
93
+ end # class LogStash::Outputs::Rollbar
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-output-rollbar'
4
+ s.version = '0.1.0'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "The Rollbar output send events to the Rollbar error monitoring service."
7
+ 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"
8
+ s.authors = ["Rollbar"]
9
+ s.email = 'support@rollbar.com'
10
+ s.homepage = "https://github.com/rollbar/logstash-output-rollbar"
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', '>= 1.4.0', '< 2.0.0'
24
+
25
+ s.add_development_dependency 'logstash-devutils'
26
+ end
27
+
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-rollbar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rollbar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '>='
17
+ - !ruby/object:Gem::Version
18
+ version: 1.4.0
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ name: logstash
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.0
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: logstash-devutils
40
+ prerelease: false
41
+ type: :development
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ 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
48
+ email: support@rollbar.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - CONTRIBUTORS
55
+ - Gemfile
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - lib/logstash/outputs/rollbar.rb
60
+ - logstash-output-rollbar.gemspec
61
+ - spec/outputs/rollbar_spec.rb
62
+ homepage: https://github.com/rollbar/logstash-output-rollbar
63
+ licenses:
64
+ - Apache License (2.0)
65
+ metadata:
66
+ logstash_plugin: 'true'
67
+ logstash_group: output
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.4.5
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: The Rollbar output send events to the Rollbar error monitoring service.
88
+ test_files:
89
+ - spec/outputs/rollbar_spec.rb