This gem contains the documentation and examples for using the New Relic REST API for RPM customers.
Rails developers can use the ActiveResource helper file found in this gem. Refer to the gem rdocs.
New Relic supports a RESTful API that can be used to list applications within a given account and enumerate the health indicators of each application. The API uses the XML response format. As a convenience, New Relic offers an ActiveResource wrapper API, but developers are welcome to work directly with the XML.
New Relic supports an api key-based authentication mechanism. The key is the api key associated with an account and can be obtained using the RPM Account settings for Integrations. This key should be passed as a request header with each request. All API calls described in this document require authentication.
API requests require HTTPS in order to ensure the API key cannot be easily read by a third party.
You will need to enable API access to your account. To do this, go to Account settings (upper right corner of the New Relic site), and then click on API + web integration. Select API access, and enable it.
- x-api-key
-
API key for account, used for authentication (required)
NewRelicApi.api_key = '<api key>'
If you are behind a proxy:
NewRelicApi.proxy = 'http://localhost:3128'
The New Relic ActiveResource-based API helper is NewRelicApi. If you are using ActiveResource to access our API you can focus on the documentation and examples contained in the Ruby Documentation.
The remainder of this document will describe our XML API.
- URL
-
https://api.newrelic.com/accounts/:account_id/applications.xml
- Method
-
GET
- Restrictions
-
None
- Active Resource Helper
Replace :account_id
with your account number. You can see this in the browser URL when you log in to api.newrelic.com.
Sample data:
<?xml version="1.0" encoding="UTF-8"?> <applications type="array"> <application> <id type="integer">123</id> <name>My Application</name> <overview-url><a href="https://api.newrelic.com/browser/agent?account_id=1&agent=123%3C">https://api.newrelic.com/browser...</a>/overview-url> </application> <application> <id type="integer">124</id> <name>My Application2</name> <overview-url><a href="https://api.newrelic.com/browser/agent?account_id=1&agent=124%3C">https://api.newrelic.com/browser...</a>/overview-url> </application> </applications>
-
Invalid API Key (403)
- URL
-
https://api.newrelic.com/api/v1/accounts/:account_id/servers.xml
- Method
-
GET
- Restrictions
-
None
Replace :account_id
with your account number. You can see this in the browser URL when you log in to api.newrelic.com.
Sample data:
<?xml version="1.0" encoding="UTF-8"?> <servers type="array"> <server> <overview-url>https://api.newrelic.com/accounts/1/servers/555</overview-url> <hostname>my-hostname.newrelic.com</hostname> <id type="integer">555</id> </server> <server> <overview-url>https://api.newrelic.com/accounts/1/servers/556</overview-url> <hostname>my-hostname-2.newrelic.com</hostname> <id type="integer">556</id> </server> <server>
-
Invalid API Key (403)
- URL
-
https://api.newrelic.com/api/v1/accounts/:account_id/servers/:id
- Method
-
DELETE
- Restrictions
-
None
Replace :account_id
with your account number. Replace :id
with the server number you want to delete. You can find your account and server number in the browser URL when you log in to api.newrelic.com and navigate to the server you want to delete. The first number in the URL is your account number and the last number is your server number.
Sample data:
<?xml version="1.0" encoding="UTF-8"?> <servers type="array"> <server name="My Server" id="123456"> <result>deleted</result> </server> <server>
Or:
<?xml version="1.0" encoding="UTF-8"?> <servers type="array"> <server name="My Server" id="123456"> <result>failed</result> </server> <server>
-
Invalid API Key (403)
This gives you the list of hosts, so you can look up application data filtered by host.
- URL
-
https://api.newrelic.com/api/v1/accounts/:account_id/applications/:app_id/hosts.xml
- Method
-
GET
- Restrictions
-
None
Replace :account_id
with your account number, and :app_id
with the application ID. You can see this in the browser URL when you log in to api.newrelic.com, or you can look up the applications using the API to view applications. JSON is also supported.
Sample data:
<?xml version="1.0" encoding="UTF-8"?> <hosts type="array"> <host> <overview-url>https://api.newrelic.com/accounts/1/applications/123_h3333</overview-url> <name>App name (my-hostname.newrelic.com)</name> <id>123_h3333</id> </host> </hosts>
-
Invalid API Key (403)
This gives you the list of instances of your application, so you can look up application data filtered by instance.
- URL
-
https://api.newrelic.com/api/v1/accounts/:account_id/applications/:app_id/instances.xml
- Method
-
GET
- Restrictions
-
None
Replace :account_id
with your account number, and :app_id
with the application ID. You can see this in the browser URL when you log in to api.newrelic.com, or you can look up the applications using the API to view applications. JSON is also supported.
Sample data:
<?xml version="1.0" encoding="UTF-8"?> <instances type="array"> <instance> <overview-url>https://api.newrelic.com/accounts/1/applications/123/instances/1441_i7584</overview-url> <name>App name (my-hostname.newrelic.com)</name> <id>1441_i7584</id> </instance> </instances>
The overview URL may vary depending on the language of your application.
-
Invalid API Key (403)
- URL
-
https://api.newrelic.com/api/v1/accounts/:account_id/applications/delete.xml
- Method
-
POST
- Parameters
-
app, a string representing the name of your application, or app_id, an integer representing the id of your application
Replace :account_id
with the your account number. You can see this in the browser URL when you log in to api.newrelic.com.
EXAMPLE 1 - Deleting an app via browser URL field We want to delete the app called “dotNet qa3” which has the app_id of 11068. The account # is 26286. The data_access_key is the API key for this account.
Actual response via browser:
<applications type="array"> <application name="dotNet qa3" id="11068"> <result>deleted</result> </application> </applications>
EXAMPLE 2 - Deleting an app via Curl
curl -H “x-api-key:4a249e3f3b437002efb6121844e0a4ee1d00942b18cfb9” ‘api.newrelic.com/api/v1/accounts/26286/applications/delete.xml?app_id=11253’
Actual response:
<?xml version="1.0" encoding="UTF-8"?> <applications type="array"> <application name="test100" id="11253"> <result>deleted</result> </application> </applications>
Sample data:
<?xml version="1.0" encoding="UTF-8"?> <applications type="array"> <application name="MyApp" id="1234"> <result>deleted</result> </application> <application name="MyApp 2" id="2345"> <result>failed</result> </application> </record> </applications>
Fetch summary metrics and threshold values (traffic light information) for one application.
- URL
-
https://api.newrelic.com/accounts/:account_id/applications/:app_id/threshold_values.xml
Replace:account_id
and:app_id
with the account and application IDs. - Method
-
GET
- Restrictions
-
This API should be called at most once per minute
- Active Resource Helper
Note: Application Busy data will only be returned to Professional and Volume customers. Errors data will only be returned to Professional and Volume customers.
Sample data:
<?xml version="1.0" encoding="UTF-8"?> <threshold-values type="array"> <threshold_value name="Apdex" begin_time="Fri Dec 12 01:22:00 +0000 2008" end_time="Fri Dec 12 01:27:00 +0000 2008" formatted_metric_value="0.96 [1.0]*" threshold_value="1" metric_value="0.96"/> <threshold_value name="Application Busy" begin_time="Fri Dec 12 01:22:00 +0000 2008" end_time="Fri Dec 12 01:27:00 +0000 2008" formatted_metric_value="3%" threshold_value="1" metric_value="3"/> <threshold_value name="CPU" begin_time="Fri Dec 12 01:22:00 +0000 2008" end_time="Fri Dec 12 01:27:00 +0000 2008" formatted_metric_value="52.86 %" threshold_value="1" metric_value="52.86"/> <threshold_value name="Memory" begin_time="Fri Dec 12 01:22:00 +0000 2008" end_time="Fri Dec 12 01:27:00 +0000 2008" formatted_metric_value="261.42 MB" threshold_value="1" metric_value="261.42"/> <threshold_value name="Errors" begin_time="Fri Dec 12 01:22:00 +0000 2008" end_time="Fri Dec 12 01:27:00 +0000 2008" formatted_metric_value="0.0 epm" threshold_value="1" metric_value="0.0"/> <threshold_value name="Response Time" begin_time="Fri Dec 12 01:22:00 +0000 2008" end_time="Fri Dec 12 01:27:00 +0000 2008" formatted_metric_value="31 ms" threshold_value="1" metric_value="31"/> <threshold_value name="Throughput" begin_time="Fri Dec 12 01:22:00 +0000 2008" end_time="Fri Dec 12 01:27:00 +0000 2008" formatted_metric_value="14028.6 cpm" threshold_value="1" metric_value="14028.6"/> <threshold_value name="DB" begin_time="Fri Dec 12 01:22:00 +0000 2008" end_time="Fri Dec 12 01:27:00 +0000 2008" formatted_metric_value="46.82 %" threshold_value="1" metric_value="46.82"/> </threshold-values>
-
Apdex is a measurement of the experience of people hitting your site, with a value between 0 and 1. Errors are poor performance lower the score.
-
Application Busy shows the count of apps (agents) reporting and the percentage of wallclock time that is spent handing requests as an average of the reporting apps. In other words, how often your app your busy handling stuff compared to the elapsed time (as a percentage).
-
CPU shows the percentage of time spent in User space by the CPU as an average of reporting apps (agents).
-
Memory shows memory usage by your app
-
Errors shows the errors per minute for your app
-
Response time show the overall response-time on average across your whole application at the app server layer (not including any browser data)
-
Throughput is the total of all activity (in requests per min) across all web transactions of your app
-
DB shows the time spent in the database as a percent of the time
-
Invalid API Key (403)
-
Unknown Application (404)
Fetch summary metrics and threshold values (traffic light information) for all applications.
- URL
-
https://api.newrelic.com/accounts.xml?include=application_health
- Method
-
GET
- Restrictions
-
This API should be called at most once per minute
- Active Resource Helper
Note: Application Busy data will only be returned to Professional and Volume customers. Errors data will only be returned to Professional and Volume customers.
Sample data:
<accounts type="array"> <account> <id>1</id> <name>New Relic Administration</name> <applications type="array"> <application> <id type="integer">5</id> <name>My Application</name> <threshold-values type="array"> <threshold_value begin_time="Fri Nov 21 20:03:00 +0000 2008" formatted_metric_value="0.96 [1.0]*" name="Apdex" end_time="Fri Nov 21 20:08:00 +0000 2008" threshold_value="1" metric_value="0.96"/> <threshold_value begin_time="Fri Nov 21 20:03:00 +0000 2008" formatted_metric_value="3%" name="Application Busy" end_time="Fri Nov 21 20:08:00 +0000 2008" threshold_value="1" metric_value="3"/> <threshold_value begin_time="Fri Nov 21 20:03:00 +0000 2008" formatted_metric_value="2.59 %" name="CPU" end_time="Fri Nov 21 20:08:00 +0000 2008" threshold_value="1" metric_value="2.59"/> <threshold_value begin_time="Fri Nov 21 20:03:00 +0000 2008" formatted_metric_value="151.62 MB" name="Memory" end_time="Fri Nov 21 20:08:00 +0000 2008" threshold_value="1" metric_value="151.62"/> <threshold_value begin_time="Fri Nov 21 20:03:00 +0000 2008" formatted_metric_value="0.0 epm" name="Errors" end_time="Fri Nov 21 20:08:00 +0000 2008" threshold_value="1" metric_value="0.0"/> <threshold_value begin_time="Fri Nov 21 20:03:00 +0000 2008" formatted_metric_value="947 ms" name="Response Time" end_time="Fri Nov 21 20:08:00 +0000 2008" threshold_value="1" metric_value="947"/> <threshold_value begin_time="Fri Nov 21 20:03:00 +0000 2008" formatted_metric_value="2.4 cpm" name="Throughput" end_time="Fri Nov 21 20:08:00 +0000 2008" threshold_value="1" metric_value="2.4"/> <threshold_value begin_time="Fri Nov 21 20:03:00 +0000 2008" formatted_metric_value="0.52 %" name="DB" end_time="Fri Nov 21 20:08:00 +0000 2008" threshold_value="1" metric_value="0.52"/> </threshold-values> </application> </applications> </account> </accounts>
-
Invalid API Key (403)
New Relic provides an HTML fragment of the dashboard view of RPM. CSS styles are included, and images linked absolutely, which enables callers to embed the response directly in their applications. Authentication is through setting the appropriate API key header as outlined above, or through the regular login cookie. When using the regular login cookie, the logged-in user’s default account’s applications will be shown.
- URL
-
https://api.newrelic.com/application_dashboard
- Method
-
GET
- Restrictions
-
This API should be called at most once per minute
- Active Resource Helper
-
None available currently
Sample data:
<div id="newrelic-rpm-2"> <div id="newrelic-rpm-2-content"> <style type="text/css" media="screen"> ...embeded styles... </style> <table id="all_applications" cellspacing="0" class="section agent_display span-16"> <thead> <tr> <th class="header">Application</th> <th title="Apdex Score is a industry-standard measurement of customer satisfaction. It is calculated essentially as weighted response time. The larger number is your Apdex Score, out of 1, and the smaller number is the threshold for an acceptable response time, in seconds." class="apdex">Apdex Score <a href="http://support.newrelic.com/faqs/general/apdex" target="_blank"><img alt="?" src="https://api.newrelic.com/images/v2/12x12/moreinfo.png?1285097852" style="border: 0px none;" /></a></th> <th title="Response Time is the average time it took to generate a response to all requests.">Resp. Time</th> <th title="Errors is the percentage of your requests that received an error as a response.">Errors</th> <th title="Throughput is total number of requests processed by your application per minute." class="throughput last">Throughput<br>(change from <abbr title="24 hours ago">24h</abbr>/<abbr title="7 days ago">7d</abbr>)</th> </tr> </thead> <tbody class="application application_1"> <tr class="application_tier data"> <td class="agent"> <img alt="Normal" src="https://api.newrelic.com/images/v2/16x16/light-green.png?1285097852" /> <span class="name"> <a href="https://api.newrelic.com/accounts/1/applications/1" class="application">RPM</a> </span> <span class="status reporting">1 Host and 5 Instances</span> </td> <td class="data apdex"> <a href="https://api.newrelic.com/accounts/1/applications/1/transactions#sort_by%3Dapdex">0.99<sub>0.025</sub></a> </td> <td class="data"><a href="https://api.newrelic.com/accounts/1/applications/1/transactions">5.7 ms</a></td> <td class="data"><a href="https://api.newrelic.com/accounts/1/applications/1/traced_errors">0.00 %</a></td> <td class="data throughput last"> <a href="https://api.newrelic.com/accounts/1/applications/1/transactions#sort_by%3Dthroughput">92 rpm</a> <div class="throughput_history"> <span class="yesterday" title="Throughput down 2% from 24 hours ago"><strong class="down ">-2%</strong></span> <span class="last_week" title="Throughput up 0% from 7 days ago"><strong class="up ">0%</strong></span> </div> </td> </tr> </tbody> </table> <script type="text/javascript" charset="utf-8"> // Link catching via event delegation var getTarget = function(x){ x = x || window.event; return x.target || x.srcElement; }; var linkCatcher = function(event){ var target = getTarget(event); var link = findLink(target); if(link !== null){ window.open(link.href); return false; } }; var findLink = function(el){ while(el.nodeName.toLowerCase() !== "body"){ if(el.nodeName.toLowerCase() === 'a'){ return el; } else { el = el.parentNode; } } return null; }; var table = document.getElementById("all_applications"); table.onclick = linkCatcher; </script> </div> </div>
-
Invalid API Key (403)
- URL
-
https://api.newrelic.com/application_dashboard?application_id=:id
Replace:id
with application ID. - Method
-
GET
- Restrictions
-
This API should be called at most once per minute
- Active Resource Helper
-
None available currently
-
application_id
: the ID of the application to view
Sample data:
<div id="newrelic-rpm-2"> <div id="newrelic-rpm-2-content"> <style type="text/css" media="screen"> ...embeded styles... </style> <table id="all_applications" cellspacing="0" class="section agent_display span-16"> <thead> <tr> <th class="header">Application</th> <th title="Apdex Score is a industry-standard measurement of customer satisfaction. It is calculated essentially as weighted response time. The larger number is your Apdex Score, out of 1, and the smaller number is the threshold for an acceptable response time, in seconds." class="apdex">Apdex Score <a href="http://support.newrelic.com/faqs/general/apdex" target="_blank"><img alt="?" src="https://api.newrelic.com/images/v2/12x12/moreinfo.png?1285097852" style="border: 0px none;" /></a></th> <th title="Response Time is the average time it took to generate a response to all requests.">Resp. Time</th> <th title="Errors is the percentage of your requests that received an error as a response.">Errors</th> <th title="Throughput is total number of requests processed by your application per minute." class="throughput last">Throughput<br>(change from <abbr title="24 hours ago">24h</abbr>/<abbr title="7 days ago">7d</abbr>)</th> </tr> </thead> <tbody class="application application_1"> <tr class="application_tier data"> <td class="agent"> <img alt="Normal" src="https://api.newrelic.com/images/v2/16x16/light-green.png?1285097852" /> <span class="name"> <a href="https://api.newrelic.com/accounts/1/applications/1" class="application">RPM</a> </span> <span class="status reporting">1 Host and 5 Instances</span> </td> <td class="data apdex"> <a href="https://api.newrelic.com/accounts/1/applications/1/transactions#sort_by%3Dapdex">0.99<sub>0.025</sub></a> </td> <td class="data"><a href="https://api.newrelic.com/accounts/1/applications/1/transactions">5.7 ms</a></td> <td class="data"><a href="https://api.newrelic.com/accounts/1/applications/1/traced_errors">0.00 %</a></td> <td class="data throughput last"> <a href="https://api.newrelic.com/accounts/1/applications/1/transactions#sort_by%3Dthroughput">92 rpm</a> <div class="throughput_history"> <span class="yesterday" title="Throughput down 2% from 24 hours ago"><strong class="down ">-2%</strong></span> <span class="last_week" title="Throughput up 0% from 7 days ago"><strong class="up ">0%</strong></span> </div> </td> </tr> </tbody> </table> <script type="text/javascript" charset="utf-8"> // Link catching via event delegation var getTarget = function(x){ x = x || window.event; return x.target || x.srcElement; }; var linkCatcher = function(event){ var target = getTarget(event); var link = findLink(target); if(link !== null){ window.open(link.href); return false; } }; var findLink = function(el){ while(el.nodeName.toLowerCase() !== "body"){ if(el.nodeName.toLowerCase() === 'a'){ return el; } else { el = el.parentNode; } } return null; }; var table = document.getElementById("all_applications"); table.onclick = linkCatcher; </script> </div> </div>
-
Invalid API Key (403)
-
Unknown Application (404)
Unlike other API requests, the deployments API will accept either a license key (in the x-license-key
header) or an API key (in the x-api-key
header). Furthermore, when using the license key, you do not need to enable the API in the account settings. This is the standard mechanism used by the agent to upload deployments from the built in capistrano recipes.
- URL
-
https://api.newrelic.com/deployments.xml
- Method
-
POST
- Active Resource Helper
Exactly one of the following is required:
-
deployment[app_name]
: The value of app_name in the newrelic.yml file used by the application. This may be different than the label that appears in the RPM UI. You can find the app_name value in RPM by looking at the label settings for your application. -
deployment[application_id]
: The application id, found in the URL when viewing the application in RPM.
Following are optional parameters:
-
deployment[changelog]
: A list of changes for this deployment -
deployment[description]
: Text annotation for the deployment — notes for you -
deployment[revision]
: A revision number (e.g., git commit SHA) -
deployment[user]
: The name of the user/process that triggered this deployment
The optional fields may be set to anything you wish, and are not validated. For example, you could set the user
to "auto deployment script"
.
Here’s an example using curl
:
curl -H "x-api-key:YOUR_API_KEY_HERE" -d "deployment[app_name]=iMyFace.ly Production" https://api.newrelic.com/deployments.xml
If you were to specify the optional description
, changelog
and user
fields, the command would look like this:
curl -H "x-api-key:YOUR_API_KEY_HERE" -d "deployment[app_name]=iMyFace.ly Production" -d "deployment[description]=This deployment was sent using curl" -d "deployment[changelog]=many hands make light work" -d "deployment[user]=Joe User" https://api.newrelic.com/deployments.xml
Fetches all metrics for an application, or allows you to use a regular expression to get a subset of the metrics. These metrics are used to retrieve metric values from the Metric Data API (below). Each metric is returned with a list of fields that are valid for that metric.
- URL
-
https://api.newrelic.com/api/v1/agents/:agent_id/metrics.:format
Replace:format
with the one of (json
,xml
,csv
).:agent_id
is either an application ID, server ID, host ID, or instance ID, from the APIs documented above. - Method
-
GET
- Restrictions
-
This API should be called at most once per minute.
For partner admins, you can use a slightly different URL to get metric names for your customers (requires partner permissions).
- URL
-
https://api.newrelic.com/api/v1/accounts/:account_id/agents/:agent_id/metrics.:format
Replace:account_id
with the account ID of the customer,:agent_id
with the application, server, host, or instance ID for the customer, and:format
with one of (json
,xml
,csv
). - Method
-
GET
- Restrictions
-
This API should be called at most once per minute.
-
re
: A regular expression to filter the metric names by. Optional. -
limit
: The number of metrics to retrieve. Optional. By default the limit is 5000.
Note: Metric names will only be returned to Pro customers.
Sample requests:
api.newrelic.com/api/v1/agents/:agent_id/metrics.xml?re=WebTransaction&limit=2
Sample data:
<?xml version="1.0" encoding="UTF-8"?> <metrics type="array"> <metric name="WebTransaction"> <fields type="array"> <field name="average_call_time"/> <field name="average_response_time"/> <field name="call_count"/> <field name="max_call_time"/> <field name="min_call_time"/> <field name="requests_per_minute"/> <field name="throughput"/> <field name="total_call_time"/> </fields> </metric> <metric name="WebTransaction/RPMCollector/AgentListener/connect"> <fields type="array"> <field name="average_call_time"/> <field name="average_response_time"/> <field name="call_count"/> <field name="max_call_time"/> <field name="min_call_time"/> <field name="requests_per_minute"/> <field name="throughput"/> <field name="total_call_time"/> </fields> </metric> </metrics>
Several different values are recorded or computed for each metric. Each value is returned in a ‘field’ in the metric data API response. Each field contains a value having a specific meaning and unit of measurement.
Time values are measured in seconds (s):
-
average_call_time
,average_response_time
: Average time spent per invocation -
max_call_time
,max_response_time
-
min_call_time
,min_response_time
-
total_call_time
-
average_exclusive_time
: Average time spent per invocation, exclusive of any time instrumented by other metrics
Some fields imply their units, or have none:
-
call_count
,throughput
: Number of calls/requests in the given time period -
requests_per_minute
: Number of calls/requests per minute in the given time period -
count
-
average_value
-
total_value
-
percent
For the error-rate metric (‘Errors/all’)
-
errors_per_minute
For memory metrics (e.g., ‘Memory/Physical’)
-
used
: in megabytes (MB)
For instance-counting metrics (e.g., ‘Instance/Busy’):
-
busy_percent
: Percentage of total app server instances busy over the given time period -
instance_count
: Count of app server instances reporting in the given time period
Apdex metrics support a particular set of fields:
-
score
: Apdex score (e.g., 0.95) -
s
: Percent of responses that are “Satisfied”, or have response times <= the Apdex “T” value -
t
: Percent of responses that are “Tolerated”, or have response times > T and <= 4T -
f
: Percent of responses that are “Frustrated”, or have response times >4T (or are errors)
-
Invalid API Key (403)
-
Invalid parameters (422) - the response body will be in the requested format and will contain the error message(s).
Returns the data values for metrics collected by New Relic for your application. You can use this API to build your own view of almost any metric data tracked by New Relic.
- URL
-
https://api.newrelic.com/api/v1/accounts/:account_id/metrics/data.:format
Replace:account_id
and:format
with your New Relic account ID (found in the URL when you access New Relic), and for format use one of (json
,xml
,csv
). - Method
-
GET
- Restrictions
-
This API is rate-limited per minute, and the limit is subject to change at any point.
For partner admins, you can use a slightly different URL to get metric data for your customers (requires partner permissions).
- URL
-
https://api.newrelic.com/api/v1/accounts/:account_id/agents/:agent_id/data.:format
Replace:account_id
with the account ID of the customer,:agent_id
with the application, server, host, or instance ID for the customer, and:format
with one of (json
,xml
,csv
). - Method
-
GET
- Restrictions
-
This API is rate-limited per minute, and the limit is subject to change at any point.
-
app
oragent_id
: Application name, or agent ID, respectively. The application name must be an exact match. You can pass in an array of apps to query by specifying app[]=First&app=Second . The agent_id is either an ID for an application, an instance, a server, or a host. You can look each of these up using our API (see documentation above for “view applications”, “view servers”, “view hosts”, “view instances”). You can query multiple agents at the same time, but they must all be of the same type: application, instance, server, or host. Examples: agent_id[]=1234&agent_id=2345 (for applications), agent_id[]=1441_i7584&agent_id=1441_i7588 (for instances), agent_id[]=123_h3333&agent_id=123_h3388 (for host filtered application data), agent_id[]=555&agent_id=556 (for server data) -
begin
: Begin time, in XML UTC format. For example:2011-04-20T15:47:00Z
(note that the New Relic site graphs are NOT in UTC format, so when comparing results, be sure to convert) -
end
: End time, in XML UTC format. For example:2011-04-20T15:52:00Z
-
metrics
: Included one or many times, this lists the metrics you are interested in. If you specify multiple metrics, the request parameter should look likemetrics[]=foo&metrics[]=bar
(append ‘[]’ to the end of the name of the parameter). You can specifymetrics[]
even if there is a single metric. -
field
: Each metric supports different fields, such as ‘average_response_time’. If the field is not valid for a given metric, you will get a blank value, and if there are no valid fields for the metrics you request, you will get an error. -
summary
: 1 or 0, defaults to 0. This determines whether you get back a single value aggregated over the entire time period, or a time series. Summary results do not include thebegin
andend
times in the result. Time series results give you a separate row for each time segment.
Note: Metric data will only be returned to Pro customers.
Sample time series request:
Sample time series data:
<?xml version="1.0" encoding="UTF-8"?> <metrics type="array"> <metric app="My Application" agent_id="123456" begin="2011-04-20T15:47:00Z" end="2011-04-20T15:48:00Z" name="ActiveRecord/all"> <field type="integer" name="average_response_time">0</field> </metric> <metric app="My Application" agent_id="123456" begin="2011-04-20T15:48:00Z" end="2011-04-20T15:49:00Z" name="ActiveRecord/all"> <field type="integer" name="average_response_time">0</field> </metric> <metric app="My Application" agent_id="123456" begin="2011-04-20T15:49:00Z" end="2011-04-20T15:50:00Z" name="ActiveRecord/all"> <field type="integer" name="average_response_time">0</field> </metric> <metric app="My Application" agent_id="123456" begin="2011-04-20T15:50:00Z" end="2011-04-20T15:51:00Z" name="ActiveRecord/all"> <field type="integer" name="average_response_time">0</field> </metric> <metric app="My Application" agent_id="123456" begin="2011-04-20T15:51:00Z" end="2011-04-20T15:52:00Z" name="ActiveRecord/all"> <field type="integer" name="average_response_time">0</field> </metric> </metrics>
Sample summary request:
Sample summary data:
<?xml version="1.0" encoding="UTF-8"?> <metrics type="array"> <metric agent_id="123456" app="My Application" name="ActiveRecord/all"> <field type="integer" name="average_response_time">0</field> </metric> </metrics>
-
Invalid API Key (403)
-
Invalid parameters (422) - the response body will be in the requested format and will contain the error message(s).
Copyright © 2012 New Relic, Inc.