ExesPoster
ExesPoster is an exception post tool to Elasticsearch.
Installation
Add this line to your application's Gemfile:
gem 'exes_poster'
And then execute:
$ bundle
Or install it yourself as:
$ gem install exes_poster
Getting Started
- To set an environment variable "ELASTICSEARCH_URL"
$ export ELASTICSEARCH_URL=localhost:9200
- Call
ExesPoster.post_exception
with caught exception in the rescue section.
require 'exes_poster'
begin
raise RuntimeError, 'hoge'
rescue => e
ExesPoster.post_exception(e)
end
- You can find exception information at your elasticsearch.
{
"_index" : "exes_index",
"_type" : "exception",
"_id" : "eIb4VGPbRB6tw0eGnUXUXA",
"_version" : 1,
"found" : true,
"_source" : {
"message" : "hoge",
"@timestamp" : "2016-09-21T16:28:09.753+09:00",
"detail" : {
"class" : "RuntimeError",
"backtrace" : [
"/PATH/TO/ERROR/FILE1.rb:123:in `block (3 levels) in <top (required)>'",
"/PATH/TO/ERROR/FILE2.rb:456:in `block (2 levels) in function'",
"/PATH/TO/ERROR/FILE3.rb:15:in `<main>'"
]
}
}
}
in Japanese
Configuration
You can set Elasticsearch url and index name.
ExesPoster.setup do |config|
config.es_url = 'example.com:9200'
config.es_index = 'hoge_test'
end
Test
- You set an environment variable DOCKER_HOST or ELASTICSEARCH_URL
$ export ELASTICSEARCH_URL=localhost:9200
or
$ eval $(docker-machine env default)
- Then exec rake
$ bundle exec rake