NRQL equivalence of APM-based alert apm_jvm_metric cpu_utilization_time

Hi I’m trying to come up with an NRQL-based alert that is the equivalence of the APM-based alert apm_jvm_metric cpu_utilization_time below:

I found some information in ProcessSample. Which one below is similar to cpu_utilization_time in APM?

  • cpuPercent (the document mentions this can go above 100%, probably not what I want)
  • cpuSystemPercent
  • cpuUserPercent
  • cpuSystemPercent + cpuUserPercent

Thank you.

Hi, @tommyongsf: If you find your application in APM, then select Metrics explorer from the sidebar menu, you can search available metrics and generate an NRQL query for them:

Here is the NRQL query for CPU utilization:

SELECT average(newrelic.timeslice.value) * 1000 AS `CPU/User/Utilization` 
FROM Metric 
WHERE metricTimesliceName = 'CPU/User/Utilization' 
  AND appName = 'Your Application'
1 Like

I found some of my applications have CPU/User/Utilization more than 100 (up to 600), is that expected? The multiplier that you use is 1000, is that correct? Thank you.

The * 1000 is to convert seconds to milliseconds. For CPU usage greater than 100%, see this document: CPU usage mismatch or usage over 100% | New Relic Documentation.

Thanks so much for quick answer. However, it is not a 1-to-1 match with the APM-based alert in my original question. Do you have a suggestion to normalize it to the 100% base? Thanks again.

Sorry, I do not have any other suggestions. Perhaps another member of the community can help. Is there a reason you must use an NRQL query, rather than the existing metric condition?

From what I know, NRQL query alert is the recommended one moving forwards, so that’s why I’m switching to it. Also I wanted to create a dashboard widget that matches the alert condition. It makes sense to have a common NRQL query for both the widget and the alert condition.

Here is another idea: If you scroll to the bottom of your APM application’s Summary page, there is a list of hosts on which the application is running. If you select the Charts tab, there is a chart showing CPU utilization per host. You can click the three-dot menu in the upper-right corner of the chart to view its underlying query:

Perhaps that query will work better for your purposes.

1 Like

Thank you. I’ve come across the same idea as well :smiley:

How to get the TransactionName in below query ?
Facet to get the transaction name (which JSP)

Goal: I want to identify the JSP correlation with the CPU/User/Utilization and memory Utilization.

SELECT average(newrelic.timeslice.value) * 1000 AS CPU/User/Utilization
FROM Metric
WHERE appName like ‘%%’
AND metricTimesliceName = ‘CPU/User/Utilization’ and scope like '%%'facet appName,metricTimesliceName since 1 hour ago

I was able to make below query work for metricTimesliceName like ‘Datastore/%’ with scope capturing the JSP name. But how to achieve the same for above CPU and Memory Utilization in Metric data.

There should be a way !

FROM Metric SELECT count(newrelic.timeslice.value) as ‘count’, average(newrelic.timeslice.value, exclusiveTime: true) as ‘Average, seconds’ WHERE appName like ‘%ABCDE%’ and scope like ‘WebTransaction/%’ and metricTimesliceName like ‘Datastore/%’ and metricTimesliceName like ‘%%’ LIMIT 100 FACET appName,scope, metricTimesliceName SINCE 1 hour ago

Please help

Hi, @nandan.chandrashekar: I do not think it is possible. New Relic does not track CPU and memory usage per transaction.