Introducing custom metrics in New Relic
New Relic is a web and mobile application performance management tool that uses custom metrics to provide greater insights into how your app is performing. Custom metrics are a collection of custom-defined performance counters with their own unique name, meaning they are unaffected by average values in the New Relic account. These metrics can be set to a greater level of granularity than New Relic’s core metrics. It is vital for business owners, developers and product managers to understand how their applications are performing in production. In order to describe custom metric performance in useful business terms, you must understand how to define and use them properly.
New Relic custom metrics are a type of metric that can be defined and set to a high level of detail. Many apps need real-time insight into how an event is affecting their business, such as when an order fails during checkout or a payment has been rejected. Custom metrics are the perfect fit for these purposes. Each custom metric can be configured to capture its own performance data and display it in a meaningful way. The name of each custom metric is arbitrary, but it should make sense to the business using the app. Custom metrics are not normalized.
How to set up custom metrics
For each custom metric, you must define at least its name, the metric (a performance counter) and its sampling interval. The sampling interval is the time between every record that you send to New Relic and the time that New Relic displays it in your account. A good rule of thumb for a sampling interval is once every 5 minutes or less. Custom metrics do not have to be defined within the New Relic API; they can be defined in either the New Relic UI or API. A custom metric is defined in New Relic when you call the setMetric method, setCustomMetric method or the addCustomMetric method. The New Relic UI is used for all metric definitions. Custom metrics can be configured, tracked and reported on by either of these interfaces. Please see the New Relic UI for more information about how to configure custom metrics using our UI. Please see the New Relic API for more information about how to configure custom metrics using the New Relic API.
Note: You can have up to 1000 custom metrics per account (one of each metric type). If you need to track more than 1000 custom metrics, contact [email protected] with your requirements.
There are three types of custom metrics: counters, gauges and percentages. Counters and gauges are New Relic’s pre-built metric types. Percentages are custom metrics that can contain numeric, decimal or integer values between 0 and 100.
What to track with custom metrics
The metrics that you define should be specific enough to define your app’s performance in terms of success and performance. For example, how many users are opening a form and how many of them are successfully completing it; how many times is an array being traversed/sliced, how much time is being spent in a particular process, what percentage of users open the application and complete it. Each custom metric must have its own definition file–an XML file named metric_define.xml –with the same filename as the custom metric. The define file should define the metric name, metric type, and sampling interval. In addition, all define files must include a unique definition id that uniquely defines this metric by its name and id. The following is an example of an XML file for the custom metric “Page Load Time (ms)”, with sampling interval of 30 seconds:
Benefits of using custom metrics
New Relic custom metrics provide greater visibility into the performance of your application. They let you focus on things that matter most to your business, while giving you the ability to analyze how your application is performing at a low level. New Relic custom metrics are easy and simple to use, so you don’t have to be an expert in statistical modeling or machine learning to get started with them. With New Relic custom metrics, companies have been able to: – Reduce false positives by identifying the cause of problems before they impact customers – Reduce outages and improve uptime – Troubleshoot performance bottlenecks and identify common performance issues – Identify points at which time is wasted. For example, each time a web request was delayed or a database transaction failed to return any results, you can put a dollar value on that time. – Save money by finding performance bottlenecks and reducing the amount of resources needed to deliver the same function  From the New Relic blog:
“It is hard to overstate the usefulness of metrics in helping companies understand, manage and optimize their applications. They’ve been proven to be a critical component in any CIO’s or BI analyst’s toolkit . ” ”
– Guy Kawasaki, Chief Evangelist for Apple Inc.
New Relic has a lot of info on custom metrics and they are a great resource for examples.
When you start searching to see what is already available on New Relic, you will probably notice that there are many pre-configured “metrics” that you could use with little or no additional work. In newer versions of New Relic, they have been “blowing up” the pre-configured metrics and have been adding new ones.
In this article, I will outline some of the pre-configured metrics and how they relate to custom metrics.
Examples of how to use custom metrics
By creating a custom metric for the number of failed login attempts, you can see whether there is a sudden increase in the number of failed login attempts in your system. This can indicate when something went wrong and it can help you find out what is causing the failure. For example, if the failure rate was at 10% previously, but recently the failed login rate has jumped to 15%, it may be a sign of trouble. Similarly by creating a custom metric for user login success rate, you can see whether there is an increase in the number of failed login attempts over a given period of time. The values of the custom metric will help you detect whether there is a sudden increase in the number of failed login attempts, and whether the time period is within the acceptable range.
Here is an example:
For more information about creating a custom metric, see Creating a Custom Metric . You can also refer to the following web pages for related information:
The New Relic UI has its own terminology for describing custom metrics. The terms used in this article may not match those used in your New Relic UI. For more information about the terms used to describe custom metrics, see Custom Metrics Terminology .
This version of the New Relic APM agent does not support custom metrics. For more information, refer to The New Relic APM Agent .