---
title: record_custom_metrics (Python agent API)
source: https://docs.newrelic.com/docs/apm/agents/python-agent/python-agent-api/recordcustommetrics-python-agent-api
---

## Syntax

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

Records a set of custom metrics.

## Description

This call records a set of [custom metrics](https://docs.newrelic.com/docs/agents/manage-apm-agents/agent-data/custom-metrics). To record a single custom metric, see [`record_custom_metric`](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/record_custom_metric).

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

```py
def metrics():
    yield "Custom/Value-1", 1
    yield "Custom/Value-2", 2
    yield "Custom/Value-3", 3

newrelic.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`](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/record_custom_metric).

## Parameters

| Parameter                   | Description                                                                                                                                                                                                                                                                                                                |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `metrics` _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`](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/record_custom_metric) parameters for more information about `name` and `value` rules and suggestions. |
| `application` _string_      | 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

None.

## Examples

### Recording custom metrics [#metrics-example]

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

newrelic.agent.record_custom_metrics(metrics())
```

## View and use custom metrics

To view custom metrics, use [metrics and events](https://docs.newrelic.com/docs/query-your-data/explore-query-data/data-explorer/introduction-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](https://docs.newrelic.com/docs/apis/rest-api-v2/requirements/new-relic-rest-api-v2-getting-started) to programmatically retrieve and use custom metric data outside of the UI. It is also possible to [create custom metric alert conditions](https://docs.newrelic.com/docs/alerts/new-relic-alerts/configuring-alert-policies/define-custom-metrics-alert-condition) to notify you or your team when your custom metric exceeds specific values.
