Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Listing subaccounts without counting events



I have the following query to determine sub account names and IDs

SELECT SUM(insightsTotalEventCount) as ‘Total Events’ FROM NrDailyUsage where insightsEventNamespace not in (‘Custom:C’,‘Custom:D’,‘Synthetics’) FACET consumingAccountId, consumingAccountName SINCE 1 days ago LIMIT 1000

Is there a simple query that will simply list the Account Names and IDs?



For just unique account names & ids, you may be able to run both of the below queries;

FROM NrDailyUsage SELECT uniques(consumingAccountName) SINCE 2 weeks ago
FROM NrDailyUsage SELECT uniques(consumingAccountId) SINCE 2 weeks ago

There’s no way to combine two uniques() functions in the one query and get a easily read output, so these will need to be run separately.

If you run combined like below, you’ll get a JSON result, rather than an easy to read list;

FROM NrDailyUsage SELECT uniques(consumingAccountName), uniques(consumingAccountId) SINCE 2 weeks ago

Results in:


Ryan. Thanks so much. This is exactly what I needed as I can process the JSON file. I am assuming that there is a one-to-one mapping, that is, account names[i] corresponds to account id[i], where i is member index.



@ep581s - In my testing, yes they are 1-1 mapped.

Here’s another example with 2 accounts - in this case the account IDs are 1-1 mapped.