New Relic recently updated the Usage page in a much more informative way, which helps us to understand how and when costs are generated. As we have to charge our users with the costs their subaccounts create with New Relic we want to provide a dashboard, where they can follow their ressource consumption at New Relic.
In order to proof that our NRQL is correct we try to match our results with the ones shown by the system provided.
This NR view https://account.newrelic.com/accounts/1510441/usage/unified shows 7.28 B Insights events for the last 30 days (on July 25th).
SELECT latest(insightsTotalEventCount) from NrDailyUsage where productLine = 'Insights' since 30 days ago
gives a totally different result ( 1.1 B ) which is completlly unreasonably small… It is slightly modified with a where clause from the documentation for current Insights usage from
When we try to get the Insights events by account, we also fail completely. As base value we take the ones from this view: https://account.newrelic.com/accounts/1510441/usage/unified/insightsEvents where stored Insights events are listed by account.
Here e.g. the biggest account is shown with 3.06 B events for the last 30 days.
We tried these queries:
SELECT latest(insightsTotalEventCount) from NrDailyUsage facet consumingAccountName where productLine = 'Insights' since 30 days ago limit 500
but this delivers 2.5 B events for the same account. Here one subaccount would have more events than the whole account. Even if the first query would return the accidentially latest record for any subaccount (instead of summarizing over all subaccounts) , this is not plausible, because I cannot find a subaccount which has the number of events from the first query.
To be honest, we are quite confused about the data model in NrDailyUsage. Could you please help to understand the data model and how we could recreate the numbers shwon on usage view.
If we use the example from the docu Paid Insights Pro usage by sub-account
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
and insert our Masteraccount -id, we get different values than shown here: