• English日本語한국어
  • Log inStart now

Node.js custom metrics

Record arbitrary performance data via an API call, for example, timing or computer resource data. Use metrics and events to search your custom metrics, create customizable charts, and add those charts to New Relic dashboards. Using custom metrics unifies your monitoring inside New Relic.

Caution

Collecting too many metrics can impact the performance of your application and your New Relic agent. To avoid data problems, keep the total number of unique custom metrics under 2000.

Name your metrics

Metric names are paths delimited by the / character. For custom metrics use this pattern:

<category>/<class>/<method>

For custom metric names, use <class>/<method> or <category>/<name>. For example, use MyCategory/My_method).

Important

For versions prior to Node.js agent v5, you need to prepend your metrics with Custom/. The agent will not automatically prepend custom metrics with this to prevent collision with internal metrics.

Record custom metrics

The public API for recording metric data consists of two methods on newrelic:

Example custom metric

Here is an example that shows how you can use metrics to track currency flowing through a site:

app.post('/cart/checkout', function(req, res) {
var total = computeCartTotal(req.user);
newrelic.recordMetric('Cart/ChargeAmount', total);
// ...
});

View custom metrics

To view custom metrics, see visualize your custom metric after creating it and metrics and events to search metrics, create customizable charts, and add those charts to New Relic dashboards.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.