Airbrake search

We need to search for specific errors quiet often, this script helps us find them without having to go through the web interface.

Usage
auth_token can be found on your settings page, it is NOT the api-key.

ruby airbrake_search.rb your-account your-auth-token | grep foo

Code

#! /usr/bin/env ruby
# http://grosser.it/2012/09/08/airbrake-search
# search for errors given a name
#
# gem install airbrake-api
# USAGE: ruby airbrake_search.rb your-account your-auth-token | grep SOMETHING
# https://your-account.airbrake.io/errors/ID

require "airbrake-api"

AirbrakeAPI.account = ARGV[0] || raise("need airbrake account as ARGV[0]")
AirbrakeAPI.auth_token = ARGV[1] || raise("need airbrake token as ARGV[1], go to airbrake -> settings, copy your auth token")
AirbrakeAPI.secure = true

page = 1
while errors = AirbrakeAPI.errors(:page => page)
  errors.each do |error|
    puts "#{error.id} -- #{error.error_class} -- #{error.error_message} -- #{error.created_at}"
  end
  $stderr.puts "Page #{page} ----------\n"
  page += 1
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s