logstash-2-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: b45676b5a27b208fa6d01f2aa8cbd3527fc0c9f0
4
+ data.tar.gz: f1d3afcb82dfeccec29e3c1f6bc0d5d0b9182536
5
+ SHA512:
6
+ metadata.gz: 38191a668bec7f8ce0fb7f9719291f306d21ea8a0e38e3840a1fad6929e35ed422403e261fef224ddf5dad761697b081d15b684ba06e6a2c26bcd459d5d88a86
7
+ data.tar.gz: 8e07e5cca818eb7fe38aa46378e9c4773ef39171ff1fb092eff5dd79bf3263e044cfd8857fcf95974be01c8f5de8b8506275560ea64c491f5b03f50b685aee33
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .bundle
3
+ vendor
@@ -0,0 +1 @@
1
+ jruby-1.7.25
@@ -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,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
@@ -0,0 +1,95 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ logstash-2-output-rollbar (0.1.0)
5
+ logstash-core-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ cabin (0.8.1)
11
+ clamp (0.6.5)
12
+ coderay (1.1.1)
13
+ concurrent-ruby (0.9.2-java)
14
+ diff-lcs (1.2.5)
15
+ ffi (1.9.12)
16
+ filesize (0.0.4)
17
+ fivemat (1.3.2)
18
+ gem_publisher (1.5.0)
19
+ gems (0.8.3)
20
+ i18n (0.6.9)
21
+ insist (1.0.0)
22
+ jrjackson (0.3.9-java)
23
+ jruby-openssl (0.9.13-java)
24
+ kramdown (1.11.1)
25
+ logstash-core (2.3.4.snapshot1-java)
26
+ cabin (~> 0.8.0)
27
+ clamp (~> 0.6.5)
28
+ concurrent-ruby (= 0.9.2)
29
+ filesize (= 0.0.4)
30
+ gems (~> 0.8.3)
31
+ i18n (= 0.6.9)
32
+ jrjackson (~> 0.3.7)
33
+ jruby-openssl (= 0.9.13)
34
+ logstash-core-event (= 2.3.4.snapshot1)
35
+ minitar (~> 0.5.4)
36
+ pry (~> 0.10.1)
37
+ rubyzip (~> 1.1.7)
38
+ stud (~> 0.0.19)
39
+ thread_safe (~> 0.3.5)
40
+ treetop (< 1.5.0)
41
+ logstash-core-event (2.3.4.snapshot1-java)
42
+ logstash-core-plugin-api (1.19.0-java)
43
+ logstash-core (>= 2.0.0, <= 2.3.4.snapshot1)
44
+ logstash-devutils (0.0.19-java)
45
+ fivemat
46
+ gem_publisher
47
+ insist (= 1.0.0)
48
+ kramdown
49
+ minitar
50
+ rake
51
+ rspec (~> 3.1.0)
52
+ rspec-wait
53
+ stud (>= 0.0.20)
54
+ method_source (0.8.2)
55
+ minitar (0.5.4)
56
+ polyglot (0.3.5)
57
+ pry (0.10.3-java)
58
+ coderay (~> 1.1.0)
59
+ method_source (~> 0.8.1)
60
+ slop (~> 3.4)
61
+ spoon (~> 0.0)
62
+ rake (11.2.2)
63
+ rspec (3.1.0)
64
+ rspec-core (~> 3.1.0)
65
+ rspec-expectations (~> 3.1.0)
66
+ rspec-mocks (~> 3.1.0)
67
+ rspec-core (3.1.7)
68
+ rspec-support (~> 3.1.0)
69
+ rspec-expectations (3.1.2)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.1.0)
72
+ rspec-mocks (3.1.3)
73
+ rspec-support (~> 3.1.0)
74
+ rspec-support (3.1.2)
75
+ rspec-wait (0.0.8)
76
+ rspec (>= 2.11, < 3.5)
77
+ rubyzip (1.1.7)
78
+ slop (3.6.0)
79
+ spoon (0.0.4)
80
+ ffi
81
+ stud (0.0.22)
82
+ thread_safe (0.3.5-java)
83
+ treetop (1.4.15)
84
+ polyglot
85
+ polyglot (>= 0.3.1)
86
+
87
+ PLATFORMS
88
+ java
89
+
90
+ DEPENDENCIES
91
+ logstash-2-output-rollbar!
92
+ logstash-devutils
93
+
94
+ BUNDLED WITH
95
+ 1.12.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,8 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "bundler/gem_tasks"
8
+ require "logstash/devutils/rake"
@@ -0,0 +1,120 @@
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
+
13
+ # Each of these config values can be specified in the plugin configuration section, in which
14
+ # case they'll apply to all events, or you can override them on an event by event basis.
15
+ #
16
+ # Your default Rollbar access token. You can override this for a specific event by adding
17
+ # a "[rollbar][access_token]" field to that event
18
+ config :access_token, :validate => :password, :required => true
19
+
20
+ # The default Rollbar environment. You can override this for a specific event by adding
21
+ # a "[rollbar][environment]" field to that event
22
+ config :environment, :validate => :string, :default => 'production'
23
+
24
+ # The default level for Rollbar events (info, warning, error) You can override this for a specific
25
+ # event by adding a "[rollbar][level]" field to that event
26
+ config :level, :validate => ['debug', 'info', 'warning', 'error', 'critical'] , :default => 'info'
27
+
28
+ # The default format for the Rollbar "message" or item title. In most cases you'll want to override
29
+ # this and build up a message with specific fields from the event. You can override this for a specific
30
+ # event by adding a "[rollbar][format]" field to that event.
31
+ config :format, :validate => :string, :default => "%{message}"
32
+
33
+ # Rollbar API URL endpoint. You shouldn't need to change this.
34
+ config :endpoint, :validate => :string, :default => 'https://api.rollbar.com/api/1/item/'
35
+
36
+ def hash_recursive
37
+ Hash.new do |hash, key|
38
+ hash[key] = hash_recursive
39
+ end
40
+ end
41
+
42
+ public
43
+ def register
44
+ require 'net/https'
45
+ require 'uri'
46
+ @rb_uri = URI.parse(@endpoint)
47
+ @client = Net::HTTP.new(@rb_uri.host, @rb_uri.port)
48
+ if @rb_uri.scheme == "https"
49
+ @client.use_ssl = true
50
+ @client.verify_mode = OpenSSL::SSL::VERIFY_PEER
51
+ end
52
+ end # def register
53
+
54
+ public
55
+ def receive(event)
56
+ return unless output?(event)
57
+
58
+ rb_item = hash_recursive
59
+
60
+ # We'll want to remove fields from data without removing them from the original event
61
+ data = JSON.parse(event.to_json)
62
+
63
+ #
64
+ # If logstash has created 'rollbar' fields, we'll use those to populate the item...
65
+ #
66
+ if data['rollbar']
67
+
68
+ merge_keys = %w{access_token client context environment fingerprint format framework
69
+ language level person platform request server title uuid }
70
+ merge_keys.each do |key|
71
+ data['rollbar'][key] && rb_item['data'][key] = data['rollbar'][key]
72
+ end
73
+ data.delete('rollbar')
74
+ end
75
+
76
+ # ...then put whatever's left in 'custom'...
77
+ rb_item['data']['custom'] = data
78
+
79
+ # ...and finally override the fields that have a specific meaning
80
+ rb_item['data']['timestamp'] = event.timestamp.to_i
81
+ rb_item['data']['level'] = @level unless rb_item['data'].has_key?('level')
82
+ rb_item['data']['environment'] = @environment unless rb_item['data'].has_key?('environment')
83
+
84
+ rb_item['data']['notifier']['name'] = 'logstash'
85
+ rb_item['data']['notifier']['version'] = Gem.loaded_specs["logstash-2-output-rollbar"].version
86
+
87
+ # Construct the message body using either:
88
+ #
89
+ # - The default format string defined above "%{message}"
90
+ # - The format string specified in the rollbar plugin config section
91
+ # - The format string specified in the [rollbar][format] event field
92
+ #
93
+ format = rb_item['data'].has_key?('format') ? rb_item['data']['format'] : @format
94
+ rb_item['data']['body']['message']['body'] = event.sprintf(format)
95
+
96
+ # Treat the [rollbar][access_token] field as a special case, since we don't need to
97
+ # include it more than once in the Rollbar item
98
+ #
99
+ if rb_item['data'].has_key?('access_token')
100
+ rb_item['access_token'] = rb_item['data']['access_token']
101
+ rb_item['data'].delete('access_token')
102
+ else
103
+ rb_item['access_token'] = @access_token.value
104
+ end
105
+
106
+
107
+ @logger.debug("Rollbar Item", :rb_item => rb_item)
108
+
109
+ begin
110
+ request = Net::HTTP::Post.new(@rb_uri.path)
111
+ request.body = JSON.dump(rb_item)
112
+ @logger.debug("Rollbar Request", :request => request.body)
113
+ response = @client.request(request)
114
+ @logger.debug("Rollbar Response", :response => response.body)
115
+
116
+ rescue Exception => e
117
+ @logger.warn("Rollbar Exception", :rb_error => e.backtrace)
118
+ end
119
+ end # def receive
120
+ end # class LogStash::Outputs::Rollbar
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = "logstash-2-output-rollbar"
4
+ s.version = "0.1.0"
5
+ s.licenses = ["Apache License (2.0)"]
6
+ s.summary = "The Rollbar Logstash output sends events to the Rollbar error monitoring service."
7
+ s.description = "This gem is a logstash plugin. Install using: $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
8
+ s.authors = ["Rollbar", "Filip Tepper"]
9
+ s.email = "support@rollbar.com"
10
+ s.homepage = "https://github.com/filiptepper/logstash-2-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-core-plugin-api", "~> 1.0"
24
+ s.add_development_dependency "logstash-devutils"
25
+ end
26
+
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-2-output-rollbar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rollbar
8
+ - Filip Tepper
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-07-06 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.0'
20
+ name: logstash-core-plugin-api
21
+ prerelease: false
22
+ type: :runtime
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ name: logstash-devutils
35
+ prerelease: false
36
+ type: :development
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: 'This gem is a logstash plugin. Install using: $LS_HOME/bin/plugin install
43
+ gemname. This gem is not a stand-alone program'
44
+ email: support@rollbar.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".ruby-version"
51
+ - CONTRIBUTORS
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - lib/logstash/outputs/rollbar.rb
58
+ - logstash-2-output-rollbar.gemspec
59
+ - spec/outputs/rollbar_spec.rb
60
+ homepage: https://github.com/filiptepper/logstash-2-output-rollbar
61
+ licenses:
62
+ - Apache License (2.0)
63
+ metadata:
64
+ logstash_plugin: 'true'
65
+ logstash_group: output
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.8
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: The Rollbar Logstash output sends events to the Rollbar error monitoring service.
86
+ test_files:
87
+ - spec/outputs/rollbar_spec.rb