• /
  • EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

Get average CPU usage per host for an app

You can use the New Relic REST API (v2) to get the average CPU usage for your application on a single host. This value appears on the APM Summary page in the Hosts table, in the column labeled CPU usage.

Get CPU usage for a host

To get the average CPU usage for one of your app's hosts, use a single command to obtain the metric names[]=CPU/User+Time with values[]=percent. This example shows the time range for the default time period (last 30 minutes):

bash
$
curl -X GET "https://api.newrelic.com/v2/applications/$APP_ID/hosts/$HOST_ID/metrics/data.json" \
>
-H "Api-Key:$API_KEY" -i \
>
-d 'names[]=CPU/User+Time&values[]=percent&summarize=true'
  • Replace $APP_ID and $API_KEY with your app ID and your API key.
  • Replace the $HOST_ID with the host id of your target host.

For additional detail:

Get CPU usage for the entire app

To get the average CPU usage for your application, use a command similar to the one in the previous example but without the reference to the host_id:

bash
$
curl -X GET "https://api.newrelic.com/v2/applications/$APP_ID/metrics/data.json" \
>
-H "Api-Key:$API_KEY" -i \
>
-d 'names[]=CPU/User+Time&values[]=percent&summarize=true'

For additional detail:

ヒント

To get the same information from the New Relic API Explorer (v2), select Applications > GET Metric Data, and include your API key. Add your application ID, and the names[]=CPU/User Time and values[]=percent metrics in the appropriate fields.

Copyright © 2024 New Relic株式会社。

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