graylog_exception_notifier 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +23 -0
- data/lib/exception_notifier/graylog_notifier.rb +65 -0
- data/lib/graylog_exception_notifier.rb +1 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 988dc7663ad0292a1806e9f8edaac3d888dc0181
|
4
|
+
data.tar.gz: 5e9373daa8654607fc2bf93edda8979a59aea961
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5bb72b456428bae588b1e91e7263daf60f536cfd39f91ea4e9e32d9204b572f64f85b5f96281306fa0dc120df9a6e07d775d7aceec1caed7064eb6b82b9d8dac
|
7
|
+
data.tar.gz: 6d1fba0bd2cafc0f0f0b69cb0ce367d2c1d552549518291fc146cb4ccd12f61b48cb18b3adbf1ece5ca3afa3ad7cbe1652fa305ead198c358e5780e38f92f1bc
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Using the [exception_notification](https://github.com/smartinez87/exception_notification) gem in Rails to send exception emails ? This gem provides a notifier class for exception_notification to send exceptions to [graylog2](https://www.graylog.org/).
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
* Add the gem to your Gemfile.
|
7
|
+
|
8
|
+
gem "graylog_exception_notifier"
|
9
|
+
|
10
|
+
|
11
|
+
* Configure the gem in `config/enviroments/production.rb`
|
12
|
+
|
13
|
+
Rails.application.config.middleware.use ExceptionNotification::Rack,
|
14
|
+
:graylog => {
|
15
|
+
:hostname => "graylog2.com",
|
16
|
+
:port => 12201,
|
17
|
+
:max_chunk_size => 'WAN',
|
18
|
+
:app_name => 'app_name'
|
19
|
+
}
|
20
|
+
|
21
|
+
## Dependencies
|
22
|
+
|
23
|
+
* [exception_notification](https://github.com/smartinez87/exception_notification) `~> 3.0`
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'gelf'
|
2
|
+
module ExceptionNotifier
|
3
|
+
class GraylogNotifier
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
standard_args = {
|
7
|
+
:hostname => "localhost",
|
8
|
+
:port => 12201,
|
9
|
+
:local_app_name => Socket::gethostname,
|
10
|
+
:facility => 'gelf_exceptions',
|
11
|
+
:max_chunk_size => 'LAN',
|
12
|
+
:level => 3
|
13
|
+
}
|
14
|
+
|
15
|
+
@args = standard_args.merge(options)
|
16
|
+
@notifier = GELF::Notifier.new(@args[:hostname], @args[:port], @args[:max_chunk_size])
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(err, options={})
|
20
|
+
env = options[:env]
|
21
|
+
begin
|
22
|
+
opts = {
|
23
|
+
:short_message => err.message,
|
24
|
+
:facility => @args[:facility],
|
25
|
+
:level => @args[:level],
|
26
|
+
:host => @args[:local_app_name],
|
27
|
+
:app_name=>@args[:app_name]
|
28
|
+
}
|
29
|
+
|
30
|
+
if err.backtrace && err.backtrace.size > 0
|
31
|
+
bc = ActiveSupport::BacktraceCleaner.new
|
32
|
+
bc.add_filter { |line| line.gsub(Rails.root.to_s, '') }
|
33
|
+
bc.add_silencer { |line| line =~ /mongrel|rvm\/gems|rubygems/ }
|
34
|
+
_backtrace = bc.clean(err.backtrace)||[]
|
35
|
+
if _backtrace.size>0
|
36
|
+
opts = opts.merge ({
|
37
|
+
:full_message => _backtrace.join("\n"),
|
38
|
+
:file => _backtrace[0].split(":")[0],
|
39
|
+
:line => _backtrace[0].split(":")[1],
|
40
|
+
})
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
unless env.nil?
|
45
|
+
request = ActionDispatch::Request.new(env)
|
46
|
+
|
47
|
+
request_items = {:url => request.original_url,
|
48
|
+
:http_method => request.method,
|
49
|
+
:ip_address => request.remote_ip,
|
50
|
+
:parameters => request.filtered_parameters,
|
51
|
+
:timestamp => Time.current}
|
52
|
+
|
53
|
+
opts[:request] = request_items
|
54
|
+
opts[:session] = request.session
|
55
|
+
opts[:cookies] = request.cookies
|
56
|
+
# opts[:environment] = request.filtered_env
|
57
|
+
end
|
58
|
+
@notifier.notify!(opts)
|
59
|
+
rescue Exception => i_err
|
60
|
+
puts "Graylog2 Exception logger. Could not send message: " + i_err.message
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'exception_notifier/graylog_notifier'
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: graylog_exception_notifier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wayne
|
8
|
+
- Deng
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: exception_notification
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '4.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '4.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: gelf
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.1.3
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.1.3
|
42
|
+
description: Use exception_notification to send rails exceptions to graylog2.
|
43
|
+
email:
|
44
|
+
- wayne.deng.cn@gmail.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- README.md
|
50
|
+
- lib/exception_notifier/graylog_notifier.rb
|
51
|
+
- lib/graylog_exception_notifier.rb
|
52
|
+
homepage: https://github.com/waynedeng/graylog_exception_notifier
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.2.0
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Send rails exceptions to graylog2 via exception_notification
|
76
|
+
test_files: []
|