Insights query examples for New Relic Browser and SPA

If you use New Relic Browser to monitor your apps, you can use New Relic Insights to query and explore your Browser event data. You can also query data for single-page apps (SPA) monitored by New Relic Browser.

Insights uses New Relic Query Language (NRQL), similar to SQL, to query your data.

Access to this feature depends on your subscription level.

JavaScript error query example

To view JavaScript errors in New Relic Insights, use Browser's JavaScriptError event:

  1. Go to insights.newrelic.com > Query.
  2. From the Query command line, run the following NRQL query:

    SELECT * FROM JavaScriptError
NRQL query for JavaScript error event

Here is an example NRQL query using the JavaScriptError event.

Insights: Browser JSerror NRQL example
insights.newrelic.com > Query: To view JavaScript error events in Insights, run the query SELECT * FROM JavaScriptError.
Attributes captured for JavaScript errors

Here is an example of the attributes that New Relic Browser captures when a JavaScriptError event occurs.

"event": {
            "deviceType": "Desktop",
            "firstErrorInSession": true,
            "releaseIds": "{\"jQuery\":\"v3.1.1\",\"multiverse\":\"98e7ab6\"}",
            "appName": "Book Staging Multiverse",
            "errorClass": "Error",
            "errorMessage": "Script error message",
            "requestUri": "/synthetic-multiverse/",
            "userAgentName": "Chrome",
            "transactionName": "Unnamed Transaction",
            "userAgentVersion": "44",
            "appId": 950582,
            "userAgentOS": "Linux",
            "timestamp": 1502262005,
            "browserInteractionID": ,
            "parentEventId": 
          }

View sample SPA data

To view a sample of your SPA data in Insights:

  1. Go to insights.newrelic.com > Data Explorer.
  2. Select BrowserInteraction or AjaxRequest.
  3. Optional: Use basic NRQL functions to query the data.

The Data explorer will switch to showing information about that event type. The chart will update, and a recent event will appear below.

To see more than one event's details, select See all samples. This will display up to 50 events.

Query your SPA data

To run NRQL queries of your SPA data:

  1. Go to insights.newrelic.com > Query.
  2. From the Query command line, start to type a query.

The Query command line will automatically suggest valid queries as you type.

SPA query examples

Here are some examples of queries you can make of your SPA data. For a complete list of all Browser attributes, see Browser default attributes for Insights.

Count route changes and page loads

To count the route changes and page loads in the past day:

SELECT count(*) FROM BrowserInteraction SINCE 1 day ago
    
Average duration of route changes and page loads

To find the average duration of route changes and page loads in the past day:

SELECT average(duration) FROM BrowserInteraction SINCE 1 day ago    
    
Slowest route changes

To find the 10 slowest route changes in the past day:

SELECT average(duration) FROM BrowserInteraction WHERE category = 'Route change' SINCE 1 day ago FACET browserInteractionName   

To find the 10 most popular route changes in the last day:

SELECT count(*) FROM BrowserInteraction WHERE category = 'Route change' since 1 day ago FACET browserInteractionName
Compare page load and route change throughput

To compare the throughput between page loads and route changes in the last day, at 1-hour increments:

SELECT count(*) FROM BrowserInteraction SINCE 1 day ago FACET category TIMESERIES 1 hour
Compare page load and route change performance

To compare the performance of page loads and route changes in the last day, at 1-hour increments:

SELECT average(duration) FROM BrowserInteraction SINCE 1 day ago FACET category TIMESERIES 1 hour
Create table using certain criteria

To create a data table of the average, minimum, and maximum Ajax counts for the 20 slowest route changes:

SELECT average(duration), average(ajaxCount), min(ajaxCount), max(ajaxCount) FROM BrowserInteraction WHERE category = 'Route change' SINCE 1 day ago FACET browserInteractionName LIMIT 20

For more help

Recommendations for learning more: