Installing Airbrake in a Rails application

ruby flag

Airbrake gem vs Airbrake Ruby

The Airbrake gem: Acts as a collection of integrations with frameworks and other libraries and is built on top of Airbrake Ruby.

Airbrake Ruby: The core library that performs exception sending, filtering sensitive values, ignoring errors, managing the configuration, and other heavy lifting.

We link to both projects in this guide and want to be clear about their responsibilities.

Integrating Airbrake in your Rails app

Install the Airbrake gem

Open up your Gemfile in your favorite text editor and add the airbrake gem.

gem 'airbrake', '~> 5.4'

NOTE: This version could be out of date, the README will always have the correct version.

To install the Airbrake gem, run from the root directory of your application.

bundle install

Configure the Airbrake gem to report to your project

This generation command is meant to be run from the root directory of your application.

rails g airbrake PROJECT_ID PROJECT_KEY

INFO: This creates the config/initializers/airbrake.rb file containing your PROJECT_ID and PROJECT_KEY along with some common config options and descriptions.

Additional configuration options are detailed in the airbrake-ruby README.

Testing your configuration

The following rake command to sends a test exception to verify your app’s configuration.

rake airbrake:test
# A successful test should result in a locate link to see your test exception
The test exception was sent. Find it here:

HELP: If you don’t see the locate link, please email the complete output of rake airbrake:test to

Ignoring errors

You can choose which errors to ignore before sending them to Airbrake with the add_filter method. This makes it simple to ignore errors based on type, message, file, region, or any other part of the error’s JSON.

For example, to ignore all StandardErrors you could use the following add_filter:

Airbrake.add_filter do |notice|
  if notice[:errors].any? { |error| error[:type] == 'StandardError' }

TIP: A good place to keep your add_filters is below your configure block in config/initializers/airbrake.rb

Filtering keys

You can use blacklist or whitelist filtering to specify keys to filter out of the payload (environment, parameters, session, etc). Before sending an error, filtered keys will be substituted with the [Filtered] label.

Deploy tracking

With deploy tracking you can send information about the deployment of your app to Airbrake. This unlocks error filtering by deploy and deploy markers are added to your error graphs.

graph with deploys

We offer several ways to track your deploys:

Supported frameworks

Since it’s not all about Rails, here are some of our favorite supported ruby frameworks:

Web frameworks

Job processing libraries

Additional libraries

More information available on GitHub

Please visit the Airbrake gem repo for more configuration options, use cases, examples, and tips.

Looking for the Heroku guide?

If so, you may prefer Getting started with Airbrake, Rails, & Heroku, in which you will create a new rails app on heroku that integrates with airbrake.