Relic Solution: A Better New Crash Alert Sent to Slack

New Relic Mobile can send you an email on the first occurrence of a unique crash for your mobile application. In theory, this is awesome. In practice, there are some drawbacks to alerting via email that we’ve all experienced:

  • The email is sent to too many people
  • You might get emails about an app that you are not responsible for
  • It only sends… emails (EMAILS!)

Fortunately, New Relic is an incredibly flexible tool, so you can set yourself up to receive new crash alerts where you want them, including everybody’s favorite: Slack.

How do you do it?

I made a Synthetics script that runs every 30 minutes and looks for any new crashes. If it finds a new crash, it sends a Slack message with a link to that particular crash. Additionally, you can configure the script to do this for specific apps. If you have several apps in your account, you can get new crash alerts sent to Slack for just the particular app(s) you care about.

Step 1 - Create an Incoming Webhook in your Slack account

Step 2 - Find the slackWebhookUri variable in the script and paste your webhook uri into the script as below:

varslackWebhookUri = 'YOUR Webhook URI HERE'

Step 3: Add the other variables needed for this to run:

  • Your Rest API Key
    var myQueryKey = '85d13fdef9cf5aa16368f406db89ee61';

  • The Insights API Query Key for the account that contains the mobile app you are concerned with
    var insightsQueryKey = 'INSIGHTS QUERY KEY'

  • The Account ID for the account that contains the mobile app your concerned with
    var accountId = YOUR ACCOUNT ID;

  • This should look like it would in a Insights ‘where’ statement for a specific app
    var appName = "YOUR APP NAME";

Step 4: Format the slack message by changing the payload variable - the default is:

var payload={"channel": "#crashalert", "username": "newrelic","text": "A new crash has occurred. It has a crash location of " + newCrashLocation + "\n <" + crashUrl +"| Click here> for details!"};

Note - Make sure you have a channel created, according to the payload variable, before you run the script

Step 5: Run the script on a 30 minutes schedule from one location

What it looks like in Slack

Ready to Get Started?

You can grab the script for this on GitHub. Let us know how it works for you!

1 Like