Insights usage: Event queries

This document describes subscription usage attributes available for paid New Relic Insights accounts and provides example NRQL queries for use in Insights or API calls. For more information about subscription usage data and how to use it, see the introduction documentation.

Data generation

Once per day, your Insights account will generate a NrDailyUsage event for every event namespace. An Insights NrDailyUsage event includes a count of the events under that namespace.

Use the New Relic event data dictionary to view the attributes for the default Insights usage events by selecting an event name:

Event Description
nrDaily Usage

Once per day, New Relic products generate a NrDailyUsage Insights event. Use the productLine attribute to identify and filter for the specific product's usage.

Event namespaces (types)

An event's namespace (indicated by the insightsEventNamespace attribute) corresponds to one or more event types that share a single data retention policy. A retention policy specifies how long Insights event data will be kept for a given account.

Event namespace (in UI) Event namespace (in NRQL) Event types
APM Transactions APM

Transaction

APM Errors APM Errors

TransactionError

Browser Browser

Ajax

PageAction

PageView

SPA Monitoring Browser:EventLog

AjaxRequest

BrowserInteraction

BrowserTiming

JS Errors Browser:JSErrors

JavaScriptError

Custom:* Custom:*

Event types stored using custom filters created by New Relic. Not applicable for most customers.

Custom Events Default

Custom event types created using New Relic agents or the Insights event REST API

Crash Event Trails Breadcrumb

MobileBreadcrumb

Mobile Crash Mobile Crash

MobileCrash

Mobile Error (for HTTP requests and HTTP errors features) Mobile Error

MobileRequest

MobileRequestError

Mobile Exception Mobile Exception

MobileHandledException

Mobile General Mobile General

Mobile

Mobile Session Mobile Session

Mobile Session

Query examples

To get the most out of your Insights usage data, you can:

For general information about how to use NRQL queries, see Introduction to usage data.

Insights writes usage events once per day. That is why these queries use since 24 hours ago or timeseries 1 day.

Here are some NRQL query examples about usage.

Stored event usage for last month

This query will tell you the "billable" number of Insights events for all accounts (masters and sub-accounts) in the hierarchy under the account where the query is run, for the last calendar month. This number is calculated as the daily average number of stored events.

SELECT rate(sum(insightsTotalEventCount)-sum(insightsIncludedEventCount), 1 day) 
AS 'Paid events' 
FROM NrDailyUsage 
SINCE last month 
UNTIL this month
Current Insights usage for an account

This query will tell you how many Insights events are currently stored for a specific account, broken down by event namespace. Note that you will need to replace YOUR_ACCOUNT_ID in these queries with your account ID.

SELECT latest(insightsTotalEventCount) 
FROM NrDailyUsage 
SINCE 24 hours ago 
WHERE consumingAccountId = YOUR_ACCOUNT_ID 
FACET insightsEventNamespace

This query will tell you the total current Insights event storage for a specific account, for all event namespaces:

SELECT sum(insightsTotalEventCount) 
FROM NrDailyUsage 
SINCE 24 hours ago 
WHERE consumingAccountId = YOUR_ACCOUNT_ID
Current Insights usage for multiple accounts

This query will tell you how many Insights events are currently stored for a list of accounts by event namespace. Note that you will need to replace LIST_OF_ACCOUNT_IDs in the query with a list of account IDs.

SELECT latest(insightsTotalEventCount) 
FROM NrDailyUsage SINCE 24 hours ago 
WHERE consumingAccountId 
IN (LIST_OF_ACCOUNT_IDs) 
FACET consumingAccountId, insightsEventNamespace 
LIMIT 100

You may need to increase the value in the limit clause to see all of the facets in this query.

Events included with other New Relic products

This query will tell you how many Insights events that are included with other New Relic product subscriptions were stored for an account, by the New Relic product that created them, over the past seven days. Note that you will need to replace YOUR_ACCOUNT_ID in the query with your account ID.

SELECT sum(insightsIncludedEventCount) 
FROM NrDailyUsage 
SINCE 7 days ago 
WHERE consumingAccountId = YOUR_ACCOUNT_ID 
FACET insightsNrProduct 
TIMESERIES 1 day
Retention periods by sub-account and event namespace

This query will tell you the total, paid, and included retention periods for the different event categories associated with the various New Relic products (such as APM Transaction events), for each sub-account under the specified master account ID. When creating your own NRQL queries, be sure to replace YOUR_ACCOUNT_ID with your specific account ID.

SELECT latest(insightsTotalRetentionInHours)/24 
AS 'Total retention, days', latest(insightsIncludedRetentionInHours)/24 
AS 'Included retention, days', (latest(insightsTotalRetentionInHours) - 
latest(insightsIncludedRetentionInHours))/24 
AS 'Paid retention, days' 
FROM NrDailyUsage where productLine='Insights' 
AND masterAccountId = YOUR_ACCOUNT_ID 
FACET consumingAccountId,consumingAccountName,insightsEventNamespace 
SINCE 1 day ago
Paid Insights Pro usage by sub-account

This query will tell you how many paid Insights Pro events are being consumed by each sub-account for the specified master account ID over the past seven days. When creating your own NRQL queries, be sure to replace YOUR_MASTER_ACCOUNT_ID in the query with your specific master account ID.

SELECT sum(insightsTotalEventCount)-sum(insightsIncludedEventCount) 
AS 'Paid events' from NrDailyUsage 
SINCE 7 days ago 
WHERE masterAccountId = YOUR_MASTER_ACCOUNT_ID 
FACET consumingAccountId, consumingAccountName 
TIMESERIES 1 day
Account hierarchy

This query is useful for seeing the account hierarchy (partnership, master, sub-accounts).

SELECT count(*) 
FROM NrDailyUsage 
FACET partnershipName,masterAccountName,masterAccountId,
consumingAccountName,consumingAccountId 
LIMIT 1000 
SINCE 1 day ago

For more help

Recommendations for learning more: