Heroku

Honeybadger has great built-in support for Heroku, including automated deployment tracking and monitoring of Heroku platform errors.

Overview

There are two ways to use Honeybadger with Heroku: via our Heroku add-on, and via a regular Honeybadger account. Each has its own unique strengths.

  • Heroku Add-On: When you purchase the Honeybadger add-on through the Heroku marketplace, you're buying access for a single project and a single user. If this is all you need, the Heroku add-on can be super convenient. But if you have several users managing errors for multiple projects, it can be a hassle...not to mention more expensive.
  • "Regular" Honeybadger Account: If you've signed up for a Honeybadger account via our website, good news! You still have access to all our Heroku-related features. We'll cover how to set that up below. You'll also get a plan that allows multiple projects and multiple users.

Converting Heroku Accounts

If you are currently a Heroku add-on customer and would like to switch to a "regular" account, we can do that. Just email us at support@honeybadger.io.

Heroku Deployment Tracking

With deployment tracking, Honeybadger is notified when you deploy your app. It's optional, but enabling it lets you do some really cool things, like:

  • Send alerts to Slack whenever your project is deployed.
  • Automatically resolve errors on deployment, so that any new occurrences after deployment will send you a new notification.
  • See which errors occurred after which deployments.

It's super easy to set up deployment tracking for your Heroku apps. Just run the following command, making sure to add your Honeybadger API key at the end:

bash
heroku webhooks:add -i api:release -l notify -u "https://api.honeybadger.io/v1/deploys/heroku?repository=git@github.com/username/projectname&environment=production&api_key=Your project API key" --app app-name

If you're using our Ruby gem, you can use the honeybadger command line tool to do the same thing:

bash
bundle exec honeybadger heroku install_deploy_notification

Heroku Platform Errors

If you're a Heroku add-on customer, platform error monitoring may already be set up. To check, run heroku drains -a APP_NAME and see if it mentions Honeybadger or "logplex.honeybadger.io". If it does, you don't need to set anything else up.

Normally, Honeybadger only sees errors that happen inside your application. On Heroku, we're able to go one step farther and monitor platform errors. These include the dreaded H12 timeouts and R99 errors you may have seen in your Heroku logs.

To capture these errors we use Heroku's log drain feature. Each line of your logs is sent to our servers in the background. We pull out the errors and throw everything else away.

To add the log drain, run the following command, replacing API_KEY with your Honeybadger project's secret token and APP_NAME with the name of your Heroku app:

bash
heroku drains:add https://logplex.honeybadger.io/heroku/v1?api_key=Your project API key-a APP_NAME

To monitor different environments in the same Honeybadger project, add the env parameter to the log drain endpoint, i.e.:

bash
heroku drains:add https://logplex.honeybadger.io/heroku/v1?api_key=Your project API key&env=production -a APP_NAME

Heroku Platform Logs

To send all of your Heroku logs into Insights (in addition to errors, as described above), create an additional log drain for your Heroku app using an API key displayed on the API keys tab of the project settings page:

bash
heroku drains:add "https://logplex.honeybadger.io/v1/events?api_key=Your project API key"

You can optionally add the env parameter to the log drain endpoint. If you do so, each payload recorded from Logplex will have a field named environment added to it. You can then add a filter for the desired environment to your queries, like filter environment::str == 'production'.

bash
heroku drains:add https://logplex.honeybadger.io/v1/events?api_key=Your project API key&env=production