Bugsnag Integration
Add Bugsnag error checks to your Service Maturity rubric.
Add a Bugsnag Integration
- In the OpsLevel app, Click Integrations in the left sidebar.
- Click on the + New Integration button.
- Click the Bugsnag tile to add the integration.
Create a Check
1. Navigate to the Rubrics sub menu under the Service Maturity menu in OpsLevel.
2. Hover over the cell that corresponds to the level and category you want your check to live in and click the + Add Check button.
3. Create a Bugsnag check.
4. Select one of the Check Templates from the dropdown.
The first check template simply checks that Bugsnag is enabled for a given service and that OpsLevel is receiving Bugsnag events.
The second check template looks for unresolved errors. If your service has more than 5 unresolved issues in Bugsnag, this test will fail and OpsLevel will notify you that you have outstanding issues.
If you wish to aim for a different target goal, you can modify either template and update its Success Condition as well as its Result Message to your liking. Here is an example that looks for less than 10 errors in production.
Completing the Setup
In order to complete your setup you’ll need to find a few key pieces of information:
- BUGSNAG_AUTH_TOKEN: The Personal Auth Token for accessing Bugsnag's API
- ORGANIZATION_ID: The ID that we'll use to look up your organization in Bugsnag
Getting your Personal Auth Token
- Log into Bugsnag
- Navigate to "My Account Settings"
- Select "Personal auth tokens" under the "Data Access API" heading
- Select "Generate New Token"
Obtaining your Organization ID
In Bugsnag you have the ability to track errors across many projects that are owned by a single organization. In order to narrow down our data access to a single organization, we'll have to find an ORGANIZATION_ID. Bugsnag doesn't currently have a UI for this, so instead we'll be using a bash command.
curl https://api.bugsnag.com/user/organizations \
-H "Authorization: token ${BUGSNAG_AUTH_TOKEN}"
You'll get a list of organizations in your response. Copy down the id's that you wish to integrate with OpsLevel
[
{
"id": "636d42b5ea946e0013f57627",
"name": "Organization Name",
...
}
]
Forwarding Bugsnag data to OpsLevel
Using the snippet provided below, you can query Bugsnag for errors on multiple projects within your organization and pipe the data to OpsLevel. We recommend using a cron job to periodically update OpsLevel with the latest Bugsnag results.
PROJECTS_PER_PAGE=50
BUGSNAG_AUTH_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
ORGANIZATION_ID=YYYYYYYYYYYYYYYYYYYYYYYY
WEBHOOK_URL='https://opslevel.com/integrations/custom_event/ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ'
url="https://api.bugsnag.com/organizations/${ORGANIZATION_ID}/projects?per_page=${PROJECTS_PER_PAGE}"
while [ "$url" ]; do
echo "\nPulling data from $url ..."
response=$(curl -si "$url" -H "Authorization: token ${BUGSNAG_AUTH_TOKEN}")
projects="$(echo "$response" | sed '1,/^\r$/d')"
echo "Posting to Opslevel..."
curl -X POST "${WEBHOOK_URL}" \
-H 'content-type: application/json' --data-binary "$projects"
# Follow any pagination links
headers=$(echo "$response" | sed '/^\r$/q')
url=$(echo "$headers" | sed -n -E 's/link: <(.*)>; rel="next".*/\1/p')
done
- Replace XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX with the Auth token that you generated earlier
- Replace YYYYYYYYYYYYYYYYYYYYYYYY with the Organization ID that you found earlier
- Replace ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ with the Webhook URL that OpsLevel generated for you
Updated almost 2 years ago