newrelic.agent.record_custom_metric(name, value, application=None)
Records a single custom metric.
Required. Name of the metric.
There are no restrictions on naming formats, but we recommends you use a
int or dict
Required. The numeric value of the metric. Can be an integer, a float, or a dictionary of values. The possible fields for a dictionary are:
Optional. The application object corresponding to the app with which you want to associate the metrics. If the application is the default value of
To record custom metrics from a distinct background thread or other code, you must pass the application object corresponding to the application to which the custom metrics are to be reported.
import newrelic.agentapplication = newrelic.agent.application()newrelic.agent.record_custom_metric('Custom/my_favorite_number', 42, application)
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.