---
title: NRQL query examples for mobile monitoring
source: https://docs.newrelic.com/docs/nrql/nrql-examples/nrql-query-examples-mobile-monitoring
---

There are several ways to [query your data](https://docs.newrelic.com/docs/using-new-relic/data/understand-data/query-new-relic-data). This document will show you some example [NRQL](https://docs.newrelic.com/docs/query-data/nrql-new-relic-query-language/getting-started/introduction-nrql) queries from mobile monitoring data. To see descriptions of the mobile-reported events and attributes available, see [Mobile events](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/mobile-default-event-attributes-insights).

## Mobile, MobileSession, and MobileCrash event query examples [#mobile-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?**

````sql
SELECT uniqueCount(uuid) FROM Mobile SINCE 1 day ago FACET name
```

````

**Location: Which regions of China have the most users?**

````sql
SELECT uniqueCount(uuid) FROM MobileSession WHERE countryCode='CN' FACET regionCode SINCE 7 days ago
```

````

**Device profile: How many users use the latest OS versions?**

````sql
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?**

````sql
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?**

````sql
SELECT histogram(memUsageMb) FROM MobileSession WHERE sessionDuration > 5
```

````

**Crashes: What are my app's most common crashes?**

````sql
SELECT count(*) FROM MobileCrash FACET crashException
```

````

**Crash rate: What is the crash rate for different versions of my app?**

````sql
SELECT percentage(uniqueCount(sessionId), WHERE category = 'Crash') AS `Crash rate` 
FROM MobileSession, MobileCrash FACET appVersion SINCE 90 days ago
```

````

## MobileRequest event query examples [#mobilerequest-examples]

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

-   [Android version 5.15.2](https://docs.newrelic.com/docs/release-notes/mobile-release-notes/android-release-notes/android-5152) or higher
-   [iOS version 6.0.0](https://docs.newrelic.com/docs/release-notes/mobile-release-notes/ios-release-notes/ios-agent-600) or higher

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](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/install-configure/upgrade-android-agent) or [iOS](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-ios/installation/upgrade-ios-agent) version, or add the required [feature flag](https://docs.newrelic.com/docs/mobile-monitoring/mobile-monitoring-ui/network-pages/analyze-network-requests-using-mobilerequest-event-data) to your app.

Below are some NRQL queries that address common use cases. Use the [`MobileRequest` attributes](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/mobile-default-event-attributes-insights#mobilerequest-attributes) to make your own NRQL queries. The last two examples use [`MobileRequestError`](#mobilerequesterror-examples) events in addition to `MobileRequest` to get an error rate.

**Error rate by request domain**

Which domains are prone to failure and error?

````sql
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?

````sql
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?

````sql
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?

````sql
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?

````sql
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?

````sql
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?

````sql
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?

````sql
SELECT count(*) / uniqueCount(sessionId) FROM MobileRequest, MobileSession FACET appName TIMESERIES
```

````

## MobileRequestError event query examples [#mobilerequesterror-examples]

Below are some NRQL queries that address common use cases. Use the [`MobileRequestError` attributes](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/mobile-default-event-attributes-insights#mobilerequesterror-attributes) to make your own NRQL queries.

**HTTP errors**

Which queries are causing the most errors?

````sql
SELECT count(*) FROM MobileRequestError WHERE errorType = 'HTTPError' FACET requestUrl
```

````

**Network failures**

What network failures are most common for my application?

````sql
SELECT count(*) FROM MobileRequestError WHERE errorType = 'NetworkFailure' FACET networkError
```

````

**Error rate by request domain**

Which domains are prone to failure and error?

````sql
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?

````sql
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?

````sql
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?

````sql
SELECT count(*) FROM MobileRequestError FACET appVersion
```

````

**Unique devices (by UUID)**

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

````sql
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)?

````sql
SELECT count(*) FROM MobileRequestError WHERE errorType = 'HTTPError' FACET requestDomain TIMESERIES
```

````

## MobileHandledException event query examples [#mobilehandledexception-examples]

Below are some NRQL queries for common [handled exception](https://docs.newrelic.com/docs/mobile-monitoring/mobile-monitoring-ui/crashes/introduction-mobile-handled-exceptions) use cases. Use the [`MobileHandledException` attributes](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/mobile-default-event-attributes-insights#mobilehandledexception-attributes) to make your own NRQL queries.

**App exceptions**

Which apps have reported the most number of handled exceptions?

````sql
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?

````sql
SELECT count(*) FROM MobileHandledException FACET exceptionLocation SINCE 3 days ago
```

````

**Most common interaction generating exceptions**

Which interaction produces the most exceptions?

````sql
SELECT count(*) FROM MobileHandledException FACET lastInteraction SINCE 3 days ago
```

````

**Most common exception message**

What are the most common reported exception messages?

````sql
SELECT count(*) FROM MobileHandledException FACET exceptionMessage SINCE 3 days ago
```

````

**Most common method reporting exceptions**

What are the most common methods reporting exceptions?

````sql
SELECT count(*) FROM MobileHandledException FACET exceptionLocationMethod SINCE 3 days ago
```

````

**Handled exception rate**

How often are handled exceptions encountered by our users?

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

````
