• /
  • Log in
  • Free account

record_custom_metrics (Python agent API)


newrelic.agent.record_custom_metrics(metrics, application=None)

Records a set of custom metrics.


This call records a set of custom metrics. To record a single custom metric, see record_custom_metric.

The passed metrics can be any iterable object that yields (name, value) tuples. For example:

def metrics(): yield 'Custom/Value-1', 1 yield 'Custom/Value-2', 2 yield 'Custom/Value-3', 3newrelic.agent.record_custom_metrics(metrics())

There are no restrictions on setting the name, but it's recommended you use a Custom/ prefix. The custom metric value can be a numeric, or can be a dictionary corresponding to an already-aggregated data sample. For more about the name and value rules, see record_custom_metric.





iterable object

Required. Set of metric values, which can be in the form of any iterable object that yields (name, value) tuples. See record_custom_metric parameters for more information about name and value rules and suggestions.



Optional. If the application is the default value of None, the agent associates the custom metrics with the parent app of the current transaction. Thus, you should provide the application unless this method is used in code for a web transaction or background task.

Return values



Recording custom metrics

def metrics():
yield 'Custom/Value-1', 1
yield 'Custom/Value-2', 2
yield 'Custom/Value-3', 3

For more help

If you need more help, check out these support and learning resources:

Create issueEdit page
Copyright © 2021 New Relic Inc.