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

List your app ID and metric timeslice data (v2)

Here are examples of how to use the New Relic REST API (v2) to get metric names and average values for a specific application ID and API key. The examples also show different time ranges.

When acquiring data, the values returned may be affected by the time period you specify and the way the data is stored. For more information, see Extracting metric timeslice data.

List all application IDs

You can also use New Relic's REST API Explorer to get the same metric timeslice data for your app information as this example.

To view all of your apps' IDs, use the following command.

bash
$
curl -X GET 'https://api.newrelic.com/v2/applications.json' \
>
-H "Api-Key:$API_KEY" -i
  • Replace $API_KEY with your API key.

The output will be an array of data where the element is an application and the data associated with it. For example, here are the first two elements for app ID 96785 ("GreatTimes Staging") and 1622 ("GreatTimes Prod"):

{
"applications": [
{
"id": 96785,
"name": "GreatTimes Staging",
"language": "ruby",
"health_status": "gray",
...
},
{
"id": 1622,
"name": "GreatTimes Prod",
"language": "ruby",
"health_status": "green",
...
}
]
}

List app ID by name

To view a specific app's ID if you know the name, substitute the name for $NAME and $API_KEY with your API key in the following command:

bash
$
curl -X GET 'https://api.newrelic.com/v2/applications.json' \
>
-H "Api-Key:$API_KEY" -i \
>
-d "filter[name]=$NAME"

The output will be the same as shown in the list all app IDs example but only for the specific application.

Metric name listing guidelines

Listing the available metric names for your application can be a very intensive operation and should only be used as necessary. Listing a large number of metric names may have a detrimental effect on your responsiveness, as well as that of other uses and may lead to invoking overload protection.

Follow these guidelines to optimize your use:

Listing metric names

Guidelines

Metric names

Carefully consider the metric names you need. If you know any part of the metric name, use the name= filter to limit the amount of data returned. This filter is a simple character match (no regular expression is available), but it can significantly reduce the amount of data retrieved.

Cache

Once you get your metric names, consider caching this list for future use. In most cases the metric names are not volatile and can be reused, saving processing time.

List metric names for your app

To view the metric names available for your application:

bash
$
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics.json" \
>
-H "Api-Key:$API_KEY" -i
  • Replace $API_KEY with your API key.

The output will be similar to the following. This shows two of the many metric names available and their values. These lists may be long. Please consider the guidelines for listing your metric names.

{
"metrics": [
{
"name": "ActiveRecord/Account/create",
"values": [
"average_response_time",
"calls_per_minute",
"call_count",
"min_response_time",
"max_response_time",
"average_exclusive_time",
"average_value",
"requests_per_minute",
"standard_deviation"
]
},
...
{
"name": "Apdex/members/destroy",
"values": [
"s",
"t",
"f",
"count",
"score",
"value",
"threshold",
"threshold_min"
]
},
...
]
}

Filter your metric name output, to return a smaller list, by specifying the name= filter like this:

bash
$
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics.json" \
>
-H "Api-Key:$API_KEY" -i \
>
-d "name=Controller/welcome/index"
  • Replace $API_KEY with your API key.

Get your app's metric timeslice data values

To view the metric timeslice data for your application:

bash
$
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
>
-H "Api-Key:$API_KEY" -i \
>
-d 'names[]=EndUser&values[]=call_count&values[]=average_response_time&summarize=true'
Copyright © 2024 New Relic Inc.

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