logstash-output-sentry 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8de667fbcb016da4649ee29c7d6193ef99af069
4
- data.tar.gz: deb9057c87497347303620fbf2bc700726cec89c
3
+ metadata.gz: 8b4b6f3febff467476f1bda31a0553447d425348
4
+ data.tar.gz: 8ae6985516d7982465dbd4f9892115ea3e44cca6
5
5
  SHA512:
6
- metadata.gz: 7145110b5052de92e18c1808be0f187edfe5084f0a7517742341f6bb08225cc770045376ad51894583a14a6500eb66730a7606e5d4f4b48c051e55f75d4486bb
7
- data.tar.gz: 3e81262b7f1bbd9b5e891bbda08fb7045b4528459392d33022926d76ccd4b450476ebdabe7915e5539aae0e249c5aaf77a7af3e873319681107811569972a3af
6
+ metadata.gz: 762fbb64d456fa1236e979f599ec45c59391e39aacca9741a0bda7406655e8b3057fbbb0bb9a8d92cae283b8ca0cfb12f7ea06a8fe06085587c37c3682733c2c
7
+ data.tar.gz: f2f5c3550935a4ba57386c75adf49ed1911dce630ba93a71ef08574a486ff8c056b6c0776b7d1dfddacb577a3a5b36be7795935820e84c6fd9d86d4231ce6a27
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.0
2
+ - Improving sentry.rb script based on antho31/logstash-output-sentry and bigpandaio/logstash-output-sentry projects.
3
+ - Creating documentation (starting from bigpandaio/logstash-output-sentry with some fixes for the differences that we have introduced to the code).
1
4
  ## 0.1.0
2
5
  - Starting project from clarkdave/logstash-sentry.rb
3
6
  - Packing script in a gem so it can be easily installed.
data/README.md CHANGED
@@ -1,89 +1,104 @@
1
- # Logstash Plugin
1
+ # Logstash-Output-Sentry Plugin
2
2
 
3
- [![Build
4
- Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-example-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-example-unit/)
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
5
4
 
6
- This is a plugin for [Logstash](https://github.com/elastic/logstash).
5
+ This plugin gives you the possibility to send your output parsed with Logstash to a Sentry host.
7
6
 
8
- 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.
7
+ This plugin 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.
9
8
 
10
- ## Documentation
11
-
12
- 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.elastic.co/guide/en/logstash/current/).
13
-
14
- - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
15
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
16
-
17
- ## Need Help?
9
+ But keep in mind that this is not an official plugin, and this plugin is not supported by the Logstash community.
18
10
 
19
- Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
20
11
 
21
- ## Developing
12
+ ## Documentation
22
13
 
23
- ### 1. Plugin Developement and Testing
14
+ ### Installation
24
15
 
25
- #### Code
26
- - To get started, you'll need JRuby with the Bundler gem installed.
16
+ You must have [Logstash](https://github.com/elasticsearch/logstash) installed for using this plugin. You can find instructions on how to install it on the [Logstash website](https://www.elastic.co/downloads/logstash). Maybe the easiest way to install is using their [repositories](https://www.elastic.co/guide/en/logstash/current/package-repositories.html).
27
17
 
28
- - 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).
18
+ As this plugin has been shared on [RubyGems](https://rubygems.org) with the name [logstash-output-sentry](https://rubygems.org/gems/logstash-output-sentry) you can install it using the following command from your Logstash installation path:
29
19
 
30
- - Install dependencies
31
20
  ```sh
32
- bundle install
21
+ bin/plugin install logstash-output-sentry
33
22
  ```
34
23
 
35
- #### Test
36
-
37
- - Update your dependencies
24
+ When installing from official repository as suggested below, the installation path is ```/opt/logstash```.
38
25
 
39
- ```sh
40
- bundle install
41
- ```
26
+ ### Usage
42
27
 
43
- - Run tests
28
+ [Sentry](https://getsentry.com/) is a modern error logging and aggregation platform.
29
+ It’s important to note that Sentry should not be thought of as a log stream, but as an aggregator.
30
+ It fits somewhere in-between a simple metrics solution (such as Graphite) and a full-on log stream aggregator (like Logstash).
44
31
 
45
- ```sh
46
- bundle exec rspec
32
+ * In Sentry, generate and get your client key (Settings -> Client key). The client key has this form:
33
+ ```
34
+ [http|https]://[key]:[secret]@[host]/[project_id]
47
35
  ```
48
36
 
49
- ### 2. Running your unpublished Plugin in Logstash
50
-
51
- #### 2.1 Run in a local Logstash clone
52
-
53
- - Edit Logstash `Gemfile` and add the local plugin path, for example:
37
+ * In your Logstash configuration file, inform your client key:
54
38
  ```ruby
55
- gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
56
- ```
57
- - Install plugin
58
- ```sh
59
- bin/plugin install --no-verify
39
+ output {
40
+ sentry {
41
+ 'key' => "yourkey"
42
+ 'secret' => "yoursecretkey"
43
+ 'project_id' => "yourprojectid"
44
+ }
45
+ }
60
46
  ```
61
- - Run Logstash with your plugin
62
- ```sh
63
- bin/logstash -e 'filter {awesome {}}'
64
- ```
65
- At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
66
47
 
67
- #### 2.2 Run in an installed Logstash
48
+ * Note that all your fields (incluing the Logstash field "message") will be in the "extra" field in Sentry. But be careful : by default , the host is set to "app.getsentry.com". If you have installed Sentry on your own machine, please change the host (change "localhost:9000" with the correct value according your configuration):
49
+ ```ruby
50
+ output {
51
+ sentry {
52
+ 'host' => "localhost:9000"
53
+ 'use_ssl' => false
54
+ 'project_id' => "yourprojectid"
55
+ 'key' => "yourkey"
56
+ 'secret' => "yoursecretkey"
57
+ }
58
+ }
59
+ ```
68
60
 
69
- 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:
61
+ * You can change the "message" field (default : "Message from logstash"), or optionally specify a field to use from your event. In case the message field doesn't exist, it'll be used as the actual message.
62
+ ```ruby
63
+ sentry {
64
+ 'project_id' => "1"
65
+ 'key' => "87e60914d35a4394a69acc3b6d15d061"
66
+ 'secret' => "596d005d20274474991a2fb8c33040b8"
67
+ 'msg' => "msg_field"
68
+ }
69
+ ```
70
70
 
71
- - Build your plugin gem
72
- ```sh
73
- gem build logstash-filter-awesome.gemspec
71
+ * You can indicate the level (default : "error"), and decide if all your Logstash fields will be tagged in Sentry. If you use the protocole HTTPS, please enable "use_ssl" (default : true), but if you use http you MUST disable ssl.
72
+ ```ruby
73
+ sentry {
74
+ 'host' => "192.168.56.102:9000"
75
+ 'use_ssl' => false
76
+ 'project_id' => "1"
77
+ 'key' => "87e60914d35a4394a69acc3b6d15d061"
78
+ 'secret' => "596d005d20274474991a2fb8c33040b8"
79
+ 'msg' => "Message you want"
80
+ 'level_tag' => "fatal"
81
+ 'fields_to_tags' => true
82
+ }
74
83
  ```
75
- - Install the plugin from the Logstash home
76
- ```sh
77
- bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
84
+
85
+ * You can optionally strip the timestamp from the sentry title by do setting `strip_timestamp` to `true`, which will change `YYYY-MM-DD HH:MM:SS,MILLISEC INFO ..` to `INFO ...`
86
+ ```ruby
87
+ sentry {
88
+ 'host' => "192.168.56.102:9000"
89
+ 'use_ssl' => false
90
+ 'project_id' => "1"
91
+ 'key' => "87e60914d35a4394a69acc3b6d15d061"
92
+ 'secret' => "596d005d20274474991a2fb8c33040b8"
93
+ 'msg' => "Message you want"
94
+ 'level_tag' => "fatal"
95
+ 'fields_to_tags' => true
96
+ 'strim_timestamp' => true
97
+ }
78
98
  ```
79
- - Start Logstash and proceed to test the plugin
80
99
 
81
100
  ## Contributing
82
101
 
83
102
  All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
84
103
 
85
- 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.
86
-
87
- It is more important to the community that you are able to contribute.
88
-
89
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
104
+ Note that this plugin has been written from [this Dave Clark's Gist](https://gist.github.com/clarkdave/edaab9be9eaa9bf1ee5f).
@@ -1,46 +1,75 @@
1
1
  # encoding: utf-8
2
- # The MIT License (MIT)
3
-
4
- # Copyright (c) 2014 Dave Clark
5
-
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
-
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
-
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
-
24
2
  require 'logstash/outputs/base'
25
3
  require 'logstash/namespace'
4
+ require 'json'
5
+
6
+ # Sentry is a modern error logging and aggregation platform.
7
+ # * https://getsentry.com/
8
+ #
9
+ # It’s important to note that Sentry should not be thought of as a log stream, but as an aggregator.
10
+ # It fits somewhere in-between a simple metrics solution (such as Graphite) and a full-on log stream aggregator (like Logstash).
11
+ #
12
+ # Generate and inform your client key (Settings -> Client key)
13
+ # The client key has this form * https://[key]:[secret]@[host]/[project_id] *
14
+ #
15
+ # More informations :
16
+ # * https://sentry.readthedocs.org/en/latest/
17
+
26
18
 
27
19
  class LogStash::Outputs::Sentry < LogStash::Outputs::Base
28
20
 
29
21
  config_name 'sentry'
30
22
 
31
- config :host, :validate => :string, :required => true, :default => 'app.getsentry.com'
23
+ # Whether to use SSL (https) or not (http)
32
24
  config :use_ssl, :validate => :boolean, :required => false, :default => true
25
+
26
+ # Sentry host
27
+ config :host, :validate => :string, :required => true, :default => 'app.getsentry.com'
28
+
29
+ # Project id, key and secret
30
+ config :project_id, :validate => :string, :required => true
33
31
  config :key, :validate => :string, :required => true
34
32
  config :secret, :validate => :string, :required => true
35
- config :project_id, :validate => :string, :required => true
33
+
34
+ # This sets the message value in Sentry (the title of your event)
35
+ config :msg, :validate => :string, :default => 'Message from logstash', :required => false
36
+
37
+ # This sets the level value in Sentry (the level tag)
38
+ config :level_tag, :validate => :string, :default => 'error', :required => false
39
+
40
+ # If set to true automatically map all logstash defined fields to Sentry extra fields.
41
+ # As an example, the logstash event:
42
+ # [source,ruby]
43
+ # {
44
+ # "@timestamp": "2013-12-10T14:36:26.151+0000",
45
+ # "@version": 1,
46
+ # "message": "log message",
47
+ # "host": "host.domain.com",
48
+ # "nested_field": {
49
+ # "key": "value"
50
+ # }
51
+ # }
52
+ # Is mapped to this Sentry event:
53
+ # [source,ruby]
54
+ # extra {
55
+ # "@timestamp": "2013-12-10T14:36:26.151+0000",
56
+ # "@version": 1,
57
+ # "message": "log message",
58
+ # "host": "host.domain.com",
59
+ # "nested_field": {
60
+ # "key": "value"
61
+ # }
62
+ # }
63
+ config :fields_to_tags, :validate => :boolean, :default => false, :required => false
36
64
 
37
65
  public
38
66
  def register
39
67
  require 'net/https'
40
68
  require 'uri'
41
-
69
+
42
70
  @url = "%{proto}://#{host}/api/#{project_id}/store/" % { :proto => use_ssl ? 'https' : 'http' }
43
71
  @uri = URI.parse(@url)
72
+
44
73
  @client = Net::HTTP.new(@uri.host, @uri.port)
45
74
  @client.use_ssl = use_ssl
46
75
  @client.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -52,20 +81,21 @@ class LogStash::Outputs::Sentry < LogStash::Outputs::Base
52
81
  def receive(event)
53
82
  return unless output?(event)
54
83
 
55
- require 'json'
56
84
  require 'securerandom'
57
85
 
58
86
  packet = {
59
87
  :event_id => SecureRandom.uuid.gsub('-', ''),
60
88
  :timestamp => event['@timestamp'],
61
- :message => event['message']
89
+ :message => event['message'] || "#{msg}",
90
+ :level => "#{level_tag}",
91
+ :platform => 'logstash',
92
+ :server_name => event['host'],
93
+ :extra => event.to_hash,
62
94
  }
63
95
 
64
- packet[:level] = event['[fields][level]']
65
-
66
- packet[:platform] = 'logstash'
67
- packet[:server_name] = event['host']
68
- #packet[:extra] = event['fields'].to_hash
96
+ if fields_to_tags
97
+ packet[:tags] = event.to_hash
98
+ end
69
99
 
70
100
  @logger.debug('Sentry packet', :sentry_packet => packet)
71
101
 
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-sentry'
3
- s.version = '0.1.0'
3
+ s.version = '0.2.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = 'This output plugin sends messages to any sentry server.'
6
- 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.'
6
+ 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 logstash-output-sentry. This gem is not a stand-alone program.'
7
7
  s.authors = ['Javier Matos Odut']
8
8
  s.email = 'iam@javiermatos.com'
9
9
  s.homepage = 'https://github.com/javiermatos/logstash-output-sentry'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-sentry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Matos Odut
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core
@@ -79,8 +79,8 @@ dependencies:
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  description: This gem is a logstash plugin required to be installed on top of the
82
- Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
83
- a stand-alone program.
82
+ Logstash core pipeline using $LS_HOME/bin/plugin install logstash-output-sentry.
83
+ This gem is not a stand-alone program.
84
84
  email: iam@javiermatos.com
85
85
  executables: []
86
86
  extensions: []