Mobile crash count and crash rate example (v2)

This describes how to use the New Relic REST API (v2) to get your Mobile application's overall and version-specific crash count and crash rate, which appear on the Mobile Overview page in the upper right corner.

These examples use the default time period of the last 30 minutes. To obtain crash data for a different time range, add the time period to the commands.

You can also use the New Relic API Explorer to retrieve Mobile metric data.

Prerequisites

To use the API in these examples, you need:

  • Your New Relic REST API key
  • Your New Relic Mobile application ID or your Mobile application version ID.

To find the Mobile application ID, see Finding the product ID: Mobile.

To find the Mobile application version ID, see Find the Mobile app version ID below.

Mobile app: Get crash data

To obtain crash count and crash rate data for the overall Mobile application, use the Mobile application ID in the following REST API command:

curl -X GET "https://api.newrelic.com/v2/mobile_applications/${MOBILE_ID}.json" \
     -H "X-Api-Key:${API_KEY}" -i 

The crash_summary output data contains both the crash_count and crash_rate.

"crash_summary": {
      "supports_crash_data": true,
      "unresolved_crash_count": 14,
      "crash_rate": 28.155339805825243
    }

To obtain crash summary data for all the mobile applications in the account, use this REST API command:

curl -X GET "https://api.newrelic.com/v2/mobile_applications.json" \
     -H "X-Api-Key:${API_KEY}" -i 

Mobile app version: Get crash count data

To obtain the crash count metric data for a specific version of the Mobile application, include the Mobile application version ID in the following REST API command:

curl -X GET "https://api.newrelic.com/v2/mobile_applications/${MOBILE_APP_VERSION}/metrics/data.json" \
     -H "X-Api-Key:${API_KEY}" -i \
     -d 'name=Mobile/Crash/All&values[]=call_count&summarize=true'

Mobile app version: Get crash rate data

To calculate a specific version's crash rate, use the following equation:

Crash Rate = (Mobile/Crash/All:call_count) / (Session/Start:call_count)

To get the two metric values needed in the equation, use the following REST API command with the Mobile application version ID .

curl -X GET "https://api.newrelic.com/v2/mobile_applications/${MOBILE_APP_VERSION}/metrics/data.json" \
    -H "X-Api-Key:${API_KEY}" -i \
    -d 'names[]=Mobile/Crash/All&names[]=Session/Start&values[]=call_count&summarize=true'

Find the Mobile app version ID

You must provide the version ID only when you want to obtain crash data for a specific version.

You can find the Mobile application version ID from the Mobile Overview page:

  1. Go to rpm.newrelic.com/mobile > (select an app) > Versions.
  2. Locate the Mobile application version ID in the URL that your browser shows when viewing the application version:

    https://rpm.newrelic.com/accounts/${ACCOUNT_ID}/mobile/${MOBILE_APP_VERSION}

For more help

Additional documentation resources include:

Recommendations for learning more: