Monitoring your applications can be tricky, especially when you have to maintain more and more of them, that uses various technologies. So that’s why programmers helps other programmers with those tasks and nowadays you can choose from various monitoring services. I was mostly focused on airbrake, but overall it seems a little bit pricey for me. I mean it’s a great piece of software that fully supports Ruby on Rails and iOS and there are bunch of addons for PHP, .Net, Java, Python - you name it. But I needed something relatively simple that could allow me to monitor my apps build with RoR and PHP only, and I found shiny piece of code named errbit.

Errbit uses official airbrake gems for contacting with your Rails apps, you can also hook it up with PHP if you want.

It runs on mongo, and I will provide here a short (very overall) quick-start guide for all interested (tested under Ubuntu 12.04 Server).

Let’s start by installing latests stable release of MongoDB, as official Ubuntu repositories are a little bit behind:

sudo su -
apt-key adv --keyserver --recv 7F0CEB10
echo "deb dist 10gen" > /etc/apt/sources.list.d/10gen.list
apt-get update && apt-get install mongodb-10gen

It will add new source list for aptitude, you may want to configure mongo for your needs after installing. Also don’t forget to create db and user on your production server - take a peak in the manual or simply login to mongo with mongo command and type:

// select db
use errbit
// give joe read/write access to the errbit database
db.addUser("joe", "PasswordOfYourChoice")

Now lets install required packages (if you’re not planning using errbit with php you can skip php5-curl).

sudo apt-get install libxml2 libxml2-dev libxslt-dev libcurl4-openssl-dev php5-curl

I assume you’ve already cloned errbit repo, personally I’m using RVM with passenger for running my apps, so don’t forget to setup .ruby-version or .rvmrc file, eg:

rvm use 1.9.3
rvm gemset create errbit
echo "[email protected]" > .ruby-version

and don’t forget about _setup_loadpaths.rb file (I’ve spent 1 hour debugging passenger and wondering why the hell it’s not picking up proper gemset, my bad :P).

# config/setup_load_paths.rb
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
    gems_path = ENV['MY_RUBY_HOME'].split(/@/)[0].sub(/rubies/,'gems')
    ENV['GEM_PATH'] = "#{gems_path}:#{gems_path}@global"
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    raise "RVM gem is currently unavailable."

# If you're not using Bundler at all, remove lines bellow
ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'

If you are good to go you can bundle install and rake errbit:bootstrap. After that take a look at config.yml and mongoid.yml and configure it for you environment. Basically that’s it - you will need to also configure proper deployment, but that’s all covered in official documentation.

In you Rails application that you want to monitor add airbrake gem to Gemfile, bundle install and create config/initializers/errbit.rb that is provided after adding application in Errbit itself.

You can also hook up PHP apps using errbit-php. It’s simple as cloning the repo, and including code below in some file that is included every request.

require_once 'errbit-php/lib/Errbit.php';

    'api_key'           => 'YOUR API KEY',
    'host'              => 'host',                               // don't try to specify port here
    'port'              => 80,                                   // optional
    'secure'            => false,                                // optional
    'project_root'      => '/your/project/root',                 // optional
    'environment_name'  => 'production',                         // optional
    'params_filters'    => array('/password/', '/card_number/'), // optional
    'backtrace_filters' => array('#/some/long/path#' => '')      // optional

It will handle any exceptions and errors (depending on your php.ini configuration) and curl your errbit instance with proper params if anything bad happens :).