Now that the new Unified Subscription Usage is available, it is easier than ever to find extensive detail on how your New Relic Usage is being calculated. For this post, I am going to focus on NrDailyUsage events in Insights. I will provide some clarity around what you can view in the Usage UI, but you can also use the Usage NRQL Query reference docs to build your own usage queries to fit your team’s specific needs!
Query Your Usage Data
Pretty much any usage calculation you see on the Overall usage page, (Account settings > Account > Usage) has an underlying Insights query. You can view these queries by hovering over a chart and clicking on the three dots in the upper right-hand corner.
You can then use the default query as a stepping stone to find the data you’re looking for by narrowing or expanding your search accordingly.
See Changes In Usage
Usage data is collected and aggregated on a 24-hour cycle. If you take a close look at the timestamps on Usage events, you’ll start to notice a pattern. Most of them are created in the same minute at the same time on every day. If you’re worried about possible duplicates, then you should be aware that data on different days represents distinct usage cycles. Lets look up the usage for a host:
SELECT * FROM NrDailyUsage WHERE hostId = ‘**host id**’ AND usageType = ‘Host’ SINCE 1 week AGO
If you try this on your account and a host has been reporting for the last week, you may find seven events. Don’t worry, this is expected behavior and reflects our 24-hour aggregation cycle.
Check Your Agent Versions
When calculating usage, it is important to make sure your agents are up to date. The newest version of your specific agent will capture the most accurate data about your environment and usage.
SELECT apmAppName, apmAppId, apmLanguage, apmAgentVersion FROM NrDailyUsage WHERE productLine = ‘APM’ AND usageType = ‘Application’ SINCE 1 day AGO
This is an example of searching by that 24-hour cycle mentioned earlier. This query will return the most recent cycle of APM usage by Application, showing what version of the agents you are running.
Why are there two
We searched by a usageType of ‘Application’ here because we wanted to know what each app on those hosts is doing. For billing purposes, we would want to query data where the usageType is ‘Host’. We can then specify if the productLine is ‘APM’ or ‘Infrastructure’. The reason querying these usageTypes returns different results is that each host can have more than one application. New Relic bills by host and not by the number of applications running on a host.
Why update your agents?
hostIdis the value we use to uniquely identify an APM host.
hostIdis derived from one of three values:
- The cloud instance Id of a host if that host is cloud-hosted (
- The linux boot ID of the host if that host is running on a Linux-based host.
agentHostnamestring that the host is configured with.
We take the first available value in that sequence:
agentHostname. This is also the way that we identify the usage of agents running in containers. However, agents before the versions listed in the minimum agent versions for containers only collect
agentHostname. AWS instance id recognition came just slightly before the rest of the values, but those versions are a good rule of thumb. This means that older agents running in the same environment as newer agents might report different kinds of unique values. This can cause them to appear as multiple hosts.
Expand Your Results
If you have a complex application architecture or are distributed across many hosts, you may notice an ‘Unknown Group’ on the Usage UI page. You can think of this as “other hosts”.
If you use the steps from earlier to view the query that generated this graph, you can find the culprit. The default
LIMIT is set to 15.
If you want to expand this you can click ‘View in Insights’ and modify the query to have a higher upper limit (up to 1000.)
That’s all I’m covering today, but I cannot recommend our usage docs enough if you have more questions. Some great places to start are the Usage UI documentation for details about the UI and what you can do there, as well as the Usage NRQL Query reference docs for more NRQL starting queries you can use to examine your usage data in more detail.