• EnglishEspañol日本語한국어Português
  • Log inStart now

Report metrics via the Metric API

Use the Metric API to send custom metrics to the New Relic platform. This document includes a quick start to send your first custom metric, plus detailed information on how to format and send your metric data.

Quick start: Send metric data

We report the metric types count, gauge, and summary. For more information on metrics see our documentation.

Metric data is submitted to New Relic through an HTTP POST request. Each request is composed of one or more metric data points, which consist of a metric name, a timestamp, and a value.

Follow this example to send your first metric data points to New Relic:

  1. Get the for the account you want to report data to.

  2. Insert the license key into the following JSON, and then send the JSON to our endpoint.

  3. Update the timestamp with a valid epoch timestamp. This example creates a single metric data point for a metric named memory.heap, but you can create additional attributes or data points by specifying metric types or adding optional common blocks.

    curl -vvv -k -H "Content-Type: application/json" \
    -X POST https://metric-api.newrelic.com/metric/v1 \
    --data '[{

The metric should be available in New Relic in a few seconds. You can query the data from any NRQL interface using this query:

FROM Metric SELECT max(memory.heap) TIMESERIES

For more on where data shows up, see Find Metric API data.

Endpoint URL

Use an HTTP POST when sending metric data to the metric API endpoint:



If your organization hosts data in the EU data center, ensure you're using the EU region endpoints. For this API, the EU endpoint is:


HTTP request headers

Include the following HTTP request headers with the POST request. You can send some parameters as query parameters instead of request headers.


Send as a query parameter?




Required. Must be application/json.



Required (usually set automatically by the HTTP client). The length of the request body in octets (8-bit bytes) unless sent with chunked encoding. This header is generally set by default by the underlying HTTP client sending the data and in most cases should not require any additional effort by the end user.



Required. A for the account you want to report data to. If this is provided as both a header and a query parameter, the values must match.



Required if GZIP. The value must be GZIP or Identity. If no value is present, then Identity is assumed.



Optional - Reserved for future use. The value must be a valid UUID4. The value is expected to be unique for each request.

HTTP request body

The body of the HTTP POST request must be in JSON format. The following describes the requirements and recommendations for the JSON payload.

The payload must be encoded as UTF-8.


The JSON payload uses this structure:

  • The JSON payload is an array of maps.
  • Each map must contain a metrics key whose value is an array containing one or more metric data points.
  • A metric data point is identified by a name, value, and timestamp along with an optional set of attributes.

Required key-value pairs

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





Required. The name of the metric. The value must be less than 255 characters.


number or map

Required. The value varies depending on the metric 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.



Required. The metric's start time in Unix time. The default uses UTC time zone. This field also support seconds, microseconds, and nanoseconds. However, the data will be converted to milliseconds for storage and query. Metrics reported with a timestamp older than 48 hours ago or newer than 24 hours from the time they are reported are dropped.


positive long

Required for count and summary metric types. The length of the time window.


Recommended. This should be one of the supported metric types. If you do not specify a type, then this will default to a gauge.


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.

Share attributes across metrics with common

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:





The metric's start time in Unix time. 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.


positive long

Required for count and summary.The length of the time window.


strings, JSON numbers, or booleans

A map of key-value pairs associated with this specific metric. Values can be strings, JSON numbers, or booleans.

Response validation and status codes

The Metric API returns a 202 response code for successful requests. When your data is accepted, an HTTP 202 response code is returned with a response structure like this:

HTTP/1.1 202 Accepted
Content-Type: application/json; charset=UTF-8
Content-Length: 52
Access-Control-Allow-Methods: GET, POST, PUT, HEAD, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive

Missing data with 202 response

A 202 code indicates the API did receive your data, and that the data passed basic validation checks. Normally, your data will be available for querying within a few seconds. However, New Relic runs additional validation asynchronously after receiving your data. If you receive a 202 response but can't find your metric, this indicates that New Relic found an error during this asynchronous validation.

You can find these errors by querying NrIntegrationError events in the account associated with the Insert API key you used. The requestId for each request will be tagged on the NrIntegrationError event. For more information, see Troubleshoot an NRIntegrationError event.

Status codes

The Metric API can return the following HTTP status codes:

Status code



Data accepted.


Structure of the request is invalid.


Authentication failure.


The request path is incorrect.


Used a request method other than POST.


The request took too long to reach the endpoint.


The Content-Length header wasn’t included.


The payload was too big. Payloads must be under 1MB (10^6 bytes).


The request URI was too long.


The Content-Type or Content-Encoding was invalid.


The request rate quota has been exceeded.


The request headers are too long.


There was a server error (please retry).

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.