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 recommend 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)
To view custom metrics, use the data explorer to search and filter for custom metrics, create customizable charts, and add those charts to New Relic dashboards. You can use our REST API to programmatically retrieve and use custom metric data outside of the UI. It is also possible to create custom metric alert conditions to notify you or your team when your custom metric exceeds specific values.