You know the feeling. You’ve just received an infrastructure alert that CPU usage has been spiking on one of your servers. You’re concerned because it’s been pinned at 100% for the last five minutes and is showing no signs of returning to normal. There are three applications running on the box and all of them are now suffering degraded response times. But you can’t tell which app is causing the issue and why things have suddenly gone haywire.
Without the right metrics, you’re likely to waste valuable time and energy before realizing you’re experiencing a fairly common issue—your Node.js application is running out of memory. All that CPU work is going toward frequent garbage collection.
Scenarios like the one described above illustrate why Node.js virtual machine runtime metrics, such as resource utilization and garbage collection statistics, are such important data points for operations and DevOps teams. Monitoring them can help avoid issues before they impact customers, and they can be helpful when troubleshooting performance issues or verifying the resolution of a problem. That’s why we’re so excited to announce the immediate availability of new runtime metrics for the Node VM (aka V8) and a dedicated Node VMs view for visualizing and analyzing this new data from the Node.js Agent for New Relic APM.
Node VMs page
The Node VMs page provides interactive, time-series charts designed to help you quickly identify anomalies and discover their root causes. Having a single place to view all of your Node VM metrics makes it easier to see the relationships between them so you can focus your investigations on the right problem. As described above, for example, it can help you see beyond a spike in CPU utilization to the corresponding jump in memory usage and garbage collection time that points to a memory leak as the potential cause.
As shown in the screenshot below, the Node VMs page is conveniently reached via the New Relic UI left-navigation. If your application is deployed across multiple servers, by default we show you a high-level overview for ‘All Servers’:
You can drill down and get additional details by selecting a specific server from the servers drop-down at the top of the page, as shown here:
Hover over any portion of the chart to see an indicator that makes it easy to correlate data across charts. Notice a spike or area of interest? Just select the region in the chart and New Relic automatically adjusts the time window to match. This time window is preserved as you explore other metrics throughout the New Relic UI. For example, you could switch to the Transactions page to view transactions and transaction traces to narrow down your search to the code paths that were active at the time of an interesting runtime metric event. Since the time window is preserved, when you switch to the transactions page it will show the transactions that were active during that same time window. If you’re looking for a problem, you might want to start with the code executed as part of one of those transactions.
Add metrics to a custom dashboard
New metrics, too
In addition to the CPU and memory usage metrics that were already available, we’ve added several new metrics to the New Relic Node.js Agent:
- Free, Used, and Max Heap reported by Node
- Non-Heap Memory used by Node for things like buffers and streams
We’ve also introduced a new optional @newrelic/native-metrics module that, when installed alongside the New Relic Node.js Agent, provides the following additional information:
- Time spent in garbage collection per minute
- Time spent in garbage collection by type of GC per minute
- Frequency of garbage collection per minute
- Total time spent actively executing in each event loop tick
- Event loop ticks per minute
(You can find a complete descriptions of the new metrics, along with minimum node and agent version requirements, in the Node.js VM measurement documentation. And look here for more information on the Node.js VMs statistics page.)
The New Relic team is thrilled to offer these deep insights into the well-being of your Node.js applications’ runtime. Node VM metrics are available now for New Relic APM customers on our Essentials, Pro, or enterprise plans. We’d love to hear your feedback on this feature—please join us in the New Relic Technical Community.