NOTE: New Relic Servers and Legacy Alerts are going away on or before May 15, 2018. Check out our post in the Online Technical Community for more information.

Get average CPU percentages (v2)


For the latest, most advanced host monitoring, check out New Relic Infrastructure.

Here are examples of how to use the New Relic REST API (v2) to obtain the average CPU percentages for your system and users for a specific server ID and API key. The examples show different time ranges.

The API calls use two metric names, System and User. Because there are multiple values, New Relic's REST API returns them in JSON or XML format. The examples here show XML.

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.

Example: Default time period

To get the average percent over the last 30 minutes (default) for your system and users, you do not need to specify the time range. For example:

curl -X GET "${SERVERID}/metrics/data.xml" \
     -H "X-Api-Key:${APIKEY}" -i \
     -d 'names[]=System/CPU/System/percent&names[]=System/CPU/User/percent&values[]=average_value&summarize=true'

You can also use API Explorer Servers > Metric Data to obtain the information in this example.

Example: Selected time period

To specify a different time range, change the from and to values. Here is an example of the same data, except it obtains the average value for a five minute period.

curl -X GET "${SERVERID}/metrics/data.xml" \
     -H "X-Api-Key:${APIKEY}" -i \
     -d 'names[]=System/CPU/System/percent&names[]=System/CPU/User/percent&values[]=average_value&from=2014-01-20T15:23:00+00:00&to=2014-01-20T15:28:00+00:00&summarize=true'

For more help

Discuss New Relic Servers in the New Relic Online Technical Community! Troubleshoot and ask questions, or discuss Servers for Linux or Servers for Windows in detail.

If you need additional help, get support at