At Airbrake, we’re all about finding ways to make it faster and easier to use Airbrake Error Monitoring and Performance Monitoring. To that end, our developers have created the Airbrake Command Line Interface (CLI). With the CLI, Airbrake users can set up new projects with Airbrake and interact with the Airbrake API conveniently from the terminal.
For quick install directions, watch our "How to Install Airbrake CLI" video or continue through our blog post for written directions.
Why use a CLI for Airbrake?
There are several benefits to using a CLI for Airbrake. With the CLI, you can easily:
- Install or add Airbrake notifier libraries to your own projects
- Conveniently interact with the Airbrake API from a terminal
- Send errors directly to Airbrake
Are you interested in trying it out? Installation and setup is easy!
Installation for Mac Users
The CLI is quick and easy to install using Homebrew.
brew install airbrake/airbrake-cli/airbrake
And that’s it!
Installation for Linux Users
To install the Airbrake CLI on Linux, find and download the latest version’s .tar.gz file from our GitHub repository: https://github.com/airbrake/airbrake-cli/releases. Extract the CLI binary from the archive and install it to
/usr/local/bin with this command:
tar xvzf airbrake*.tar.gz -C /usr/local/bin
If desired, change the directory in the command above to extract the file to another location.
There are several ways you can authenticate your account. You can login by issuing the following command:
Provide your email address, password, and your account’s subdomain.
Enter your email: email@example.com
Enter your password:
Enter your subdomain (optional):
Done! The Airbrake CLI is configured for firstname.lastname@example.org
If you’re using GitHub or SSO for authentication, you’ll need to take additional steps.
Now, use the CLI to interact with the Airbrake API!
See Your Projects
See what projects you have in your account using:
<code>airbrake projects list</code>
This command will return a response from the Airbrake API containing all your projects.
What else can the CLI currently do? Use the help flag to explore the
Install an Airbrake Notifier in Your Project:
The CLI helps bootstrap a new project by installing, or adding, the Airbrake libraries to your project. This requires that you go to the directory of your project’s source code in your terminal before using the commands below.
For a project that already exists in your Airbrake account, use the install command to add an Airbrake notifier to your project’s source code. The CLI will try to detect what kind of project you have and add the necessary pieces for you. Hint: you’ll need a project ID for this scenario which you can find using the projects list command (described above).
<code>airbrake install --project-id YOUR_PROJECT_ID</code>
To create a new project in your Airbrake account, and add an Airbrake notifier to your source code for that project, use this command:
<code>airbrake install --create-project=DESIRED_PROJECT_NAME</code>
After installing an Airbrake notifier in your project, your project is ready to be monitored for errors.
Sending Errors from the Command Line:
The Airbrake CLI can also send errors directly to Airbrake. This feature is useful for something like shell scripting. To send errors in this way, all you need is your Airbrake project’s ID (which you can find using the
airbrake projects list command).
<code>airbrake notices create --project-id YOUR_PROJECT_ID --type "Test Error" --message "CLI test error"</code>
You can specify any “type” or “message” you want, and the CLI will send it to your Airbrake project!
So Much More You Can Do!
This article has explained how you can use the Airbrake CLI to add a notifier to your software and to send custom errors from the command line. Use
airbrake --help to learn what else you can do from the Airbrake CLI, like recording deployments.
Keep an eye out for future updates as Airbrake continues to add to our Command-Line Interface.