logstash-output-airbrake 0.1.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
+ SHA1:
3
+ metadata.gz: 438a6c7c1d4fe1068cbbcb429556765886344e5b
4
+ data.tar.gz: 6a4d572f4768c81554b668dd76788f8d1577f3ae
5
+ SHA512:
6
+ metadata.gz: dd2a7c869bd78cfb27f86fe1c2bcaadcefa8e607e74520053dd4b91712ee93be1b2ae06039cbb1a4c74f8e0edd6a4aa28b105d568ae017cd9ffd8d4ae1cb1618
7
+ data.tar.gz: 62fe4f1d39f35323445cfe4384a2d8378d0498cc3d13ef7dcec890e52dc6db69e661d3cc7982963911b28b10bcb6680645cfe45795aa534442f0d6eb88226e5c
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ .bundle
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README-TEA.md ADDED
@@ -0,0 +1,52 @@
1
+ logstash-output-airbrake
2
+ ========================
3
+
4
+ ## Installation de l'environnement de développement
5
+
6
+ Les plugins logstash sont écrit en ruby mais Logstash nécessite JRuby. La
7
+ première étape consiste donc à l'installer :
8
+
9
+ ```bash
10
+ rbenv install jruby-9.0.0.0.pre1 # la version peut changer
11
+ rbenv global jruby-9.0.0.0.pre1
12
+ ```
13
+
14
+ On doit ensuite installer bundler pour cette version de ruby :
15
+
16
+ ```bash
17
+ gem install bundler
18
+ ```
19
+
20
+ ## Tester le plugin sur un serveur logstash local
21
+
22
+ Dans le répertoire du plugin, installer les dépendances :
23
+
24
+ ```bash
25
+ bundle install
26
+ ```
27
+
28
+ Puis construire la gem du plugin (si on compte la distribuer, sinon pas besoin) :
29
+
30
+ ```bash
31
+ gem build logstash-output-airbrake.gemspec
32
+ ```
33
+
34
+ Exécuter le plugin avec une installation de Logstash *depuis les sources* :
35
+
36
+ - Éditer le `Gemfile` de Logstash pour y ajouter le plugin :
37
+ ```ruby
38
+ gem "logstash-output-airbrake", :path => "/home/kevin/sandbox/logstash-output-airbrake"
39
+ ```
40
+
41
+ - Installer le plugin :
42
+ ```sh
43
+ bin/plugin install --no-verify
44
+ ```
45
+
46
+ - Exécuter Logstash avec le plugin :
47
+ ```sh
48
+ ./bin/logstash --verbose -e 'input { stdin {} } output { airbrake{ api_key => "joe la frite" } }'
49
+ ```
50
+
51
+ Les modifications faites au plugin seront partagées avec l'installation faite
52
+ dans Logstash, il suffit de le redémarrer pour qu'elles soient prises en compte.
data/README.md ADDED
@@ -0,0 +1,98 @@
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 unit tests
41
+
42
+ ```sh
43
+ bundle exec rspec
44
+ ```
45
+
46
+ - Run integration tests
47
+
48
+ Dependencies: [Docker](http://docker.com)
49
+
50
+ Before the test suite is run, we will load and run an
51
+ Elasticsearch instance within a docker container. This container
52
+ will be cleaned up when suite has finished.
53
+
54
+ ```sh
55
+ bundle exec rspec --tag integration
56
+ ```
57
+
58
+ ### 2. Running your unpublished Plugin in Logstash
59
+
60
+ #### 2.1 Run in a local Logstash clone
61
+
62
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
63
+ ```ruby
64
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
65
+ ```
66
+ - Install plugin
67
+ ```sh
68
+ bin/plugin install --no-verify
69
+ ```
70
+ - Run Logstash with your plugin
71
+ ```sh
72
+ bin/logstash -e 'filter {awesome {}}'
73
+ ```
74
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
75
+
76
+ #### 2.2 Run in an installed Logstash
77
+
78
+ 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:
79
+
80
+ - Build your plugin gem
81
+ ```sh
82
+ gem build logstash-filter-awesome.gemspec
83
+ ```
84
+ - Install the plugin from the Logstash home
85
+ ```sh
86
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
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/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rake"
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ require "logstash/namespace"
3
+ require "logstash/outputs/base"
4
+
5
+ require "airbrake"
6
+
7
+ # This output lets you send logs to Airbrake.
8
+ class LogStash::Outputs::Airbrake < LogStash::Outputs::Base
9
+ milestone 1
10
+
11
+ config_name "airbrake"
12
+
13
+ # The API Key to use to send notifications to Airbrake.
14
+ config :api_key, :validate => :string, :required => true
15
+
16
+ # The error type to use when sending notifications.
17
+ # Defaults to "RuntimeError"
18
+ config :error_type, :validate => :string, :default => "RuntimeError"
19
+
20
+ # The environment name.
21
+ # Defaults to "logstash"
22
+ config :environment, :validate => :string, :default => "logstash"
23
+
24
+ # Host of the Airbrake server.
25
+ config :host, :validate => :string
26
+
27
+ # Port of the Airbrake server.
28
+ config :port, :validate => :number
29
+
30
+ public
31
+ def register
32
+ Airbrake.configure do |c|
33
+ c.api_key = @api_key
34
+ c.environment_name = @environment
35
+
36
+ c.host = @host if @host
37
+ c.port = @port if @port
38
+ c.secure = @port.to_i == 443
39
+ end
40
+ end # def register
41
+
42
+ public
43
+ def receive(event)
44
+ return unless output?(event)
45
+
46
+ Airbrake.notify(
47
+ :error_class => @error_type,
48
+ :error_message => event['message'],
49
+ :parameters => event.to_hash
50
+ )
51
+ end # def receive
52
+
53
+ end # class LogStash::Outputs::Airbrake
@@ -0,0 +1,28 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "logstash-output-airbrake"
3
+ s.version = "0.1.0"
4
+ s.licenses = ["MIT"]
5
+ s.summary = "Logstash Output to Airbrake"
6
+ s.description = "Output events to Airbrake"
7
+ s.authors = ["TEA"]
8
+ s.email = 'technique@tea-ebook.com'
9
+ s.homepage = "http://www.tea-ebook.com/"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = `git ls-files`.split($\)
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", ">= 1.4.0", "< 2.0.0"
23
+
24
+ s.add_runtime_dependency "airbrake", ['~> 4.0']
25
+
26
+ s.add_development_dependency "logstash-input-generator"
27
+ s.add_development_dependency "logstash-devutils"
28
+ end
@@ -0,0 +1,55 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+
3
+ require "logstash/pipeline"
4
+ require "logstash/outputs/airbrake"
5
+
6
+ describe LogStash::Outputs::Airbrake do
7
+ subject { klass.new(settings) }
8
+
9
+ let(:klass) { LogStash::Outputs::Airbrake }
10
+
11
+ let(:api_key) { "dummy api key" }
12
+ let(:error_type) { "some error_type" }
13
+ let(:environment) { "some environment" }
14
+ let(:host) { "airbrake host" }
15
+ let(:port) { 4242 }
16
+ let(:settings) {
17
+ {
18
+ "api_key" => api_key,
19
+ "error_type" => error_type,
20
+ "environment" => environment,
21
+ "host" => host,
22
+ "port" => port
23
+ }
24
+ }
25
+
26
+ before do
27
+ allow(Airbrake).to receive(:configure)
28
+
29
+ subject.register
30
+ end
31
+
32
+ describe "#register" do
33
+ it "should create cleanly" do
34
+ expect(subject).to be_a(klass)
35
+ end
36
+
37
+ it "should configure airbrake" do
38
+ expect(Airbrake).to have_received(:configure).once
39
+ end
40
+ end
41
+
42
+ describe "#receive" do
43
+ let(:event) { LogStash::Event.new("foo" => "bar") }
44
+
45
+ before do
46
+ allow(Airbrake).to receive(:notify)
47
+
48
+ subject.receive(event)
49
+ end
50
+
51
+ it "should forward the event to Airbrake" do
52
+ expect(Airbrake).to have_received(:notify).once
53
+ end
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-airbrake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - TEA
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core
15
+ requirement: !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
+ type: :runtime
24
+ prerelease: false
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
+ name: airbrake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '4.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '4.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: logstash-input-generator
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: logstash-devutils
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: Output events to Airbrake
76
+ email: technique@tea-ebook.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - ".rspec"
83
+ - Gemfile
84
+ - README-TEA.md
85
+ - README.md
86
+ - Rakefile
87
+ - lib/logstash/outputs/airbrake.rb
88
+ - logstash-output-airbrake.gemspec
89
+ - spec/outputs/airbrake_spec.rb
90
+ homepage: http://www.tea-ebook.com/
91
+ licenses:
92
+ - MIT
93
+ metadata:
94
+ logstash_plugin: 'true'
95
+ logstash_group: output
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.2.2
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Logstash Output to Airbrake
116
+ test_files:
117
+ - spec/outputs/airbrake_spec.rb
118
+ has_rdoc: