---
title: Collect custom metrics (APM, browser, mobile)
source: https://docs.newrelic.com/docs/apm/agents/manage-apm-agents/agent-data/collect-custom-metrics
---

APM agents, browser agents, and mobile agents report a type of metric data called [metric timeslice data](https://docs.newrelic.com/docs/using-new-relic/data/understand-data/new-relic-data-types#timeslice-data). These agents allow you to report custom metric timeslice data from your application and see it alongside default New Relic data. Create custom metrics to record arbitrary performance data via an API call, such as:

-   Timing data
-   Computer resource data
-   Subscription or purchasing data

After reporting this data, you can [explore and query it](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/nrql-query-tutorials/query-apm-metric-timeslice-data-nrql).

## Name custom metrics [#naming]

Start all custom metric names with `Custom/`; for example, `Custom/MyMetric/My_label`. The `Custom/` prefix is required for all custom metrics.

Any custom metric names that do not start with `Custom/` are subject to all other grouping rules. They may not be visible when querying, or they may not appear as expected in the UI.

![custom-metric-syntax](https://docs.newrelic.com/images/apm_diagram_custom-metric-syntax.webp "custom-metric-syntax")

A custom metric name consists of the prefix `Custom/`, the category or class name, and a method or label, each separated with a slash.

## Implement custom metrics [#implementing]

Implementing custom metrics requires API calls. The exact details of the API call vary by agent.

> #### 💡 TIP
>
> If you are testing your custom metric implementation, run the agent for at least 10 minutes to ensure that the API call is reported to New Relic.

| New Relic agent         | Implementation                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| APM agents              | - **C SDK:** [`newrelic_record_custom_metric()`](https://newrelic.github.io/c-sdk/libnewrelic_8h.html#aee71182588ace508cc816044d2024ff3) - **Go:** [`app.RecordCustomMetric`](https://docs.newrelic.com/docs/agents/go-agent/instrumentation/create-custom-metrics-go) - **Java:** [`recordMetric`](http://newrelic.github.io/java-agent-api/javadoc/com/newrelic/api/agent/NewRelic.html#recordMetric(java.lang.String,%20float)) - **.NET:** [`RecordMetric`](https://docs.newrelic.com/docs/agents/net-agent/net-agent-api/recordmetric-net-agent) - **Node.js:** [`recordMetric`](https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/nodejs-custom-metrics) - **PHP:** [`newrelic_custom_metric`](https://docs.newrelic.com/docs/agents/php-agent/php-agent-api/newrelic_custom_metric) - **Python:** [`record_custom_metric` and `register_data_source`](https://docs.newrelic.com/docs/python/python-custom-metrics) - **Ruby:** [`record_metric` and `increment_metric`](https://docs.newrelic.com/docs/ruby/ruby-custom-metrics) |
| New Relic mobile agents | [Record custom metrics SDK](https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/record-custom-metrics/)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| New Relic browser agent | Browser does not support custom metrics. For options on adding custom data to browser, see [browser instrumentation](https://docs.newrelic.com/docs/browser/new-relic-browser/page-load-timing-resources/instrumentation-browser-monitoring).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

## Avoid grouping issues [#best_practices]

Collecting too many metric timeslices can impact the performance of both your application and New Relic. For example, if you have thousands of individual users, avoid creating metrics to track the performance of their unique user IDs. This could result in such a large number of metrics that it becomes nearly impossible to navigate or make sense of the data. Instead, use a placeholder, such as an asterisk (\*), instead of individual user IDs.

> #### ⚠️ IMPORTANT
>
> To avoid potential data problems, try to keep the total number of unique metric timeslices introduced by custom metrics under 2000.

When the total number of unique metric names exceeds 5,000, limits begin to apply automatically that affect how data appears in the user interface, such as in charts and tables. For more information, see [Metric grouping issues](https://docs.newrelic.com/docs/features/metric-grouping-issues).
