---
title: Send metrics to New Relic
source: https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/newrelic/ingest/newrelic-ingest-send-metrics
---

Sends metric data points to New Relic.

For prerequisites, see [New Relic Ingest actions](https://docs.newrelic.com/docs/workflow-automation/setup-and-configure/actions-catalog/newrelic/ingest/newrelic-ingest#prerequisites).

## Send metrics to New Relic

The action identifier is `newrelic.ingest.sendMetrics`.

Sends metrics to New Relic.

### Inputs

The following table describes all available input fields for this action.

| Input          | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Example                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| -------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **metrics**    | List   | **Required.** List of metric data points. See [Required key-value pairs in the `metrics`](#metrics-key-value-pairs) for the expected structure of each item.                                                                                                                                                                                                                                                                                                | `[ { "name": "service.errors.all", "type": "count", "value": 9, "attributes": { "service.response.statuscode": "400" } }, ` `{ "name": "service.errors.all", "type": "gauge", "value": 4, "attributes": { "service.response.statuscode": "500" } }, ` `{ "name": "service.response.duration", "type": "summary", "value": { "count": 5, "sum": 0.004382655, "min": 0.0005093, "max": 0.001708826 }, "attributes": { "service.response.statuscode": "200" } } ]` |
| **attributes** | Map    | **Optional.** Common attributes to apply across all metrics. See [Share attributes across metrics with `common`](#common-attributes) for details.                                                                                                                                                                                                                                                                                                           | `{ "timestamp": 1531414060739, "interval.ms": 10000, "attributes": { "app.name": "foo", "host.name": "dev.server.com" } }`                                                                                                                                                                                                                                                                                                                                      |
| **licenseKey** | String | **Optional.** The New Relic Account License Key specifies the target account for your events. If not provided, the system uses the default license key from the account executing the workflow. [Read more about our API keys](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys#license-key) to create and manage your New Relic Account License Key. Do not input credentials in plain text. Use the secrets syntax shown in the example. | `"{{ .secrets.secretName }}"`, where `secretName` is the key under which the license key is stored.                                                                                                                                                                                                                                                                                                                                                             |
| **selectors**  | List   | **Optional.** The selectors to get only the specified parameters as output.                                                                                                                                                                                                                                                                                                                                                                                 | `[{"name": "error", "expression": ".errorMessage"}]`                                                                                                                                                                                                                                                                                                                                                                                                            |

#### Required key-value pairs in the `metrics` [#metrics-key-value-pairs]

Each metric data point map in the `metrics` list uses the following key-value structure:

| Attribute       | Type                               | Description                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **name**        | String                             | **Required.** The name of the metric. The value must be less than 255 characters.                                                                                                                                                                                                                                                                                                                              |
| **value**       | Number or Map                      | **Required.** The value varies depending on the [metric type](https://docs.newrelic.com/docs/data-apis/understand-data/metric-data/metric-data-type/). For `gauge` and `count` the value should be a single number. For `summary`, the value should be a map with key-value pairs specifying the count, sum, min, and max.                                                                                     |
| **timestamp**   | Long                               | **Optional.** The metric's start time in [Unix time](https://currentmillis.com/). The default uses UTC time zone. This field also supports seconds, microseconds, and nanoseconds. However, the data will be converted to milliseconds for storage and query. Metrics are dropped if they have a timestamp more than 48 hours in the past or more than 24 hours in the future from the time they are reported. |
| **interval.ms** | Positive long                      | **Required** for `count` and `summary` [metric types](https://docs.newrelic.com/docs/data-apis/understand-data/metric-data/metric-data-type/). The length of the time window.                                                                                                                                                                                                                                  |
| **type**        | String                             | **Recommended.** Supports only `count`, `gauge`, `summary`. See [supported metric types](https://docs.newrelic.com/docs/data-apis/understand-data/metric-data/metric-data-type/) for more information. If you do not specify a type, this defaults to a `gauge`.                                                                                                                                               |
| **attributes**  | Strings, JSON numbers, or Booleans | **Recommended.** A map of key-value pairs associated with this specific metric. Values can be strings, JSON numbers, or booleans. Keys are case-sensitive and must be less than 255 characters.                                                                                                                                                                                                                |

> #### ⚠️ IMPORTANT
>
> The metrics API mandates a `timestamp`. Within the action, the `timestamp` is optional, defaulting to the current time if not supplied prior to metrics ingestion.

#### Share attributes across metrics with `common` [#common-attributes]

If you want to include a set of attributes on multiple metrics (and not add the same attributes for each metric), you can use the `common` block. This is an optional map that specifies information that applies to all associated metric data points. Values in the `common` section will be overridden if the same key exists on a metric data point.

The block can include:

| Attribute       | Type                               | Description                                                                                                                                                                                                                                                                      |
| --------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **timestamp**   | Long                               | The metric's start time in [Unix time](https://currentmillis.com/). This defaults to the current time in the UTC time zone. This field also supports seconds, microseconds, and nanoseconds. However, the data will be converted to milliseconds for storage and later querying. |
| **interval.ms** | Positive long                      | **Required** for `count` and `summary`. The length of the time window.                                                                                                                                                                                                           |
| **attributes**  | Strings, JSON numbers, or Booleans | A map of key-value pairs associated with this specific metric. Values can be strings, JSON numbers, or booleans.                                                                                                                                                                 |

### Outputs

The following table describes all output fields returned by this action.

| Output           | Type    | Description                                                                                          |
| ---------------- | ------- | ---------------------------------------------------------------------------------------------------- |
| **requestId**    | String  | The request identifier assigned by the metrics API. Example: `13325ef9-0001-b193-510f-019ba20b0792`. |
| **success**      | Boolean | `true` on success, `false` on failure.                                                               |
| **errorMessage** | String  | Failure reason as message. `null` on success.                                                        |

### Example

The following example sends two metric data points — a count and a gauge — with timestamps and status-code attributes.

| Workflow example                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ```yaml   - name: sendMetrics     type: action     action: newrelic.ingest.sendMetrics     version: 1     inputs:       metrics:         - name: service.errors.all           type: count           value: 9           timestamp: 1531414060739           attributes:             service.response.statuscode: 400         - name: service.response.duration           type: guage           value: 4           timestamp: 1531414060733           attributes:             service.response.statuscode: 500 ``` |
