NRQL query examples for Mobile monitoring

There are several ways to query your data. This document will show you some example NRQL queries of New Relic Mobile data. To see descriptions of the Mobile-reported events and attributes available, see Mobile events.

Mobile, MobileSession, and MobileCrash event query examples

Mobile queries allow you to understand and compare a wide variety of mobile data, including interactions, location, device profile, app version, crashes, and performance.

These examples use queries made on the Mobile, MobileSession, and MobileCrash ​event types:

Interactions: Which interactions are most popular among my users?
SELECT uniqueCount(uuid) FROM Mobile SINCE 1 day ago FACET name
Location: Which regions of China have the most users?
SELECT uniqueCount(uuid) FROM MobileSession WHERE countryCode='CN' FACET regionCode SINCE 7 days ago
Device profile: How many users use the latest OS versions?
SELECT uniqueCount(uuid) FROM MobileSession FACET osVersion SINCE 7 days ago
App version: Have we seen an increase in session duration since yesterday's release?
SELECT percentile(sessionDuration, 90) FROM MobileSession since 1 day ago compare with 2 days ago
Performance: How much memory does my app use for sessions longer than 5 seconds?
SELECT histogram(memUsageMb) FROM MobileSession WHERE sessionDuration > 5
Crashes: What are my app's most common crashes?
SELECT count(*) FROM MobileCrash FACET crashException
Crash rate: What is the crash rate for different versions of my app?
SELECT percentage(uniqueCount(sessionId), WHERE category = 'Crash') as `Crash rate` FROM MobileSession, MobileCrash facet appVersion since 90 days ago

MobileRequest event query examples

This feature requires Mobile agent version 5.14.0 or higher. MobileRequest data is enabled by default for:

For earlier versions, starting with Android version 5.14.0 or iOS version 5.14.0, you must enable the feature. Upgrade to the latest Android or iOS version, or add the required feature flag to your app.

Below are some NRQL queries that address common use cases. Use the MobileRequest attributes to make your own NRQL queries. The last two examples use MobileRequestError events in addition to MobileRequest to get an error rate.

Error rate by request domain

Which domains are prone to failure and error?

SELECT percentage(count(*), where errorType = 'NetworkFailure' OR errorType = 'HTTPError') as 'Error Rate %', count(*) as '# of Requests', filter(count(*), where errorType='NetworkFailure' OR errorType='HTTPError' as '# of Errors') FROM MobileRequestError, MobileRequest facet requestDomain
Error rate for business-critical API

What is the error rate seen by our mobile apps for the most business-critical API?

SELECT percentage(count(*), where errorType = 'NetworkFailure' OR errorType = 'HTTPError') as 'Error Rate %', count(*) as '# of Requests', filter(count(*), where errorType='NetworkFailure' OR errorType='HTTPError' as '# of Errors') FROM MobileRequestError, MobileRequest facet requestPath where requestPath = '{MY_API_PATH}'
Response time percentiles of important APIs

For important requests in the 90th percentile, what is the response time by URL?

SELECT percentile(responseTime, 90), latest(requestUrl) as 'Latest URL' from MobileRequest facet cases(where requestUrl like '%{YOUR_CORE_API}%' as 'Core API', where requestUrl like '%{YOUR_FEATURE_API}%' as 'New Feature API')
Volume of network requests

How much network traffic from the apps are backend services receiving?

SELECT count(*) FROM MobileRequest FACET requestDomain since 3 days ago
Slow response user impact

What % of users are impacted by http response times greater than 3 seconds?

SELECT filter(uniqueCount(MobileRequest.uuid), WHERE responseTime > 3) / uniqueCount(MobileSession.uuid) * 100 as '% Users Impacted' FROM MobileRequest, MobileSession since 1 day ago timeseries compare with 2 days ago
Response time distribution by domain, carrier, ASN owner, country, etc.

What is the distribution of response time and request count across domain, country, carrier, or ASN owner?

SELECT histogram(responseTime, 20, 20) FROM MobileRequest since 3 days ago facet asnOwner
Percentile response time

What is the breakdown of response time by different percentiles?

  SELECT percentile(responseTime, 98) as '98 percentile (sec)', percentile(responseTime, 90) as '90 percentile (sec)',  percentile(responseTime, 50) as '50 percentile (sec)' from MobileRequest since 3 days ago
Requests per session

How do requests per session compare across different apps or subsequent builds of those apps?

SELECT count(*)/uniqueCount(sessionId) from MobileRequest, MobileSession facet appName timeseries

MobileRequestError event query examples

Below are some NRQL queries that address common use cases. Use the MobileRequestError attributes to make your own NRQL queries.

For more information and examples, see the our blog post explaining the power of MobileRequestError event data.

HTTP errors

Which queries are causing the most errors?

SELECT count(*) FROM MobileRequestError where errorType = 'HTTPError' FACET requestUrl
Network failures

What network failures are most common for my application?

SELECT count(*) FROM MobileRequestError where errorType = 'NetworkFailure' facet networkError
Error rate by request domain

Which domains are prone to failure and error?

SELECT percentage(count(*), where errorType = 'NetworkFailure' OR errorType = 'HTTPError') as 'Error Rate %', count(*) as '# of Requests', filter(count(*), where errorType='NetworkFailure' OR errorType='HTTPError' as '# of Errors') FROM MobileRequestError, MobileRequest facet requestDomain
Error rate for business-critical API

What is the error rate in our mobile apps for the most business-critical API?

SELECT percentage(count(*), where errorType = 'NetworkFailure' OR errorType = 'HTTPError') as 'Error Rate %', count(*) as '# of Requests', filter(count(*), where errorType='NetworkFailure' OR errorType='HTTPError' as '# of Errors') FROM MobileRequestError, MobileRequest facet requestPath where requestPath = '{MY_API_PATH}'
Error rate: Percentage of users impacted

How many users are experiencing errors as compared to my total user count?

SELECT filter(uniqueCount(MobileRequestError.uuid), WHERE errorType = 'HTTPError') / uniqueCount(MobileSession.uuid) * 100 as '% Users Impacted by Errors' FROM MobileRequestError, MobileSession COMPARE WITH 7 days AGO
Errors by version

Which version(s) of my app are causing the most errors?

SELECT count(*) FROM MobileRequestError FACET appVersion
Unique devices (by UUID)

Which unique devices (by UUID) are having the most issues with my application?

SELECT count(*), latest(device), latest(carrier), latest(asnOwner), latest(countryCode) FROM MobileRequestError FACET deviceUuid  limit 100 SINCE 1 days ago
Historical HTTP error counts

What does my historical HTTP Error count look like (by domain)?

SELECT count(*) FROM MobileRequestError where errorType = 'HTTPError' FACET requestDomain timeseries

MobileHandledException event query examples

Below are some NRQL queries for common handled exception use cases. Use the MobileHandledException attributes to make your own NRQL queries.

App exceptions

Which apps have reported the most number of handled exceptions?

SELECT count(*) FROM MobileHandledException FACET appName SINCE 3 days ago
Top exception locations

What are most common exception locations for my application? How many exceptions do we have, and where do they occur?

SELECT count(*) FROM MobileHandledException FACET exceptionLocation SINCE 3 days ago
Most common interaction generating exceptions

Which interaction produces the most exceptions?

SELECT count(*) FROM MobileHandledException FACET lastInteraction SINCE 3 days ago
Most common exception message

What are the most common reported exception messages?

SELECT count(*) FROM MobileHandledException FACET exceptionMessage SINCE 3 days ago
Most common method reporting exceptions

What are the most common methods reporting exceptions?

SELECT count(*) FROM MobileHandledException FACET exceptionLocationMethod SINCE 3 days ago
Handled exception rate

How often are handled exceptions encountered by our users?

SELECT percentage(uniqueCount(sessionId), WHERE exceptionLocation IS NOT NULL) FROM MobileSession,MobileHandledException SINCE 3 days ago

For more help

If you need more help, check out these support and learning resources: