Get disk I/O data (v2)

Disk I/O data appears on the New Relic Servers Disks page in the I/O rate (KB/s) and I/O operations per second charts.

This is an example of how to use the New Relic REST API (v2) to find disk I/O statistics for a specific server ID and API key. The default time range of the last 30 minutes has been changed to one week.

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.

Disk I/O rates (KB/s)

To get the disk I/O data rate (KB/s) for a specific disk for the selected time period (one week in this example), use the appropriate metric name to return read or write operations.

For Read operations, use System/Disk/${DISK_NAME}/Reads/bytes/sec. For example:

curl -X GET 'https://api.newrelic.com/v2/servers/{SERVER_ID}/metrics/data.xml' \
     -H "X-Api-Key:{API_KEY}" -i \
     -d 'names[]=System/Disk/^dev^xvda1/Reads/bytes/sec&values[]=per_second&from=2014-09-17T21:00:00+00:00&to=2014-09-24T21:00:00+00:00&summarize=false' 

For Write operations, use System/Disk/${DISK_NAME}/Writes/bytes/sec. For example:

curl -X GET 'https://api.newrelic.com/v2/servers/{SERVER_ID}/metrics/data.xml' \
     -H "X-Api-Key:${API_KEY}" -i \
     -d 'names[]=System/Disk/^dev^xvda1/Writes/bytes/sec&values[]=per_second&from=2014-09-17T21:00:00+00:00&to=2014-09-24T21:00:00+00:00&summarize=false'

You can obtain the average values for the time period by changing false to true in these commands.

Convert bytes (API) to kilobytes (New Relic UI)

The API returns disk rate data in bytes, but the New Relic UI shows kilobytes on the New Relic Servers Disks page (based on 1024 bytes in a kilobyte). To match the values obtained from your API calls with the values that appear in the UI, use this calculation:

I/O rate (KB/s) = <per_second> / 1024

Disk I/O operations per second

To obtain the disk I/O operations per second for a specific disk for the selected time period (one week in this example), use the appropriate metric name to return read or write operations.

For Read operations, use System/Disk/${DISK_NAME}/Reads/count/sec. For example:

curl -X GET "https://api.newrelic.com/v2/servers/${SERVER_ID}/metrics/data.xml"\
    -H "X-Api-Key:${API_KEY}" -i\
    -d 'names[]=System/Disk/${DISK_NAME}/Reads/count/sec&values[]=per_second&from=2014-09-17T21:00:00+00:00&to=2014-09-24T21:00:00+00:00&summarize=false'

For Write operations, use System/Disk/${DISK_NAME}/Writes/count/sec. For example:

curl -X GET "https://api.newrelic.com/v2/servers/${SERVER_ID}/metrics/data.xml"\
    -H "X-Api-Key:${API_KEY}" -i\
    -d 'names[]=System/Disk/${DISK_NAME}/Writes/count/sec&values[]=per_second&from=2014-09-17T21:00:00+00:00&to=2014-09-24T21:00:00+00:00&summarize=false'

To get the average values for the time period, change false to true in these commands.

Disk names

Replace the placeholder ${DISK_NAME} with the appropriate string. This depends on the type of system being used.

  • For Windows, use these string values: D:, E:, etc.
  • For Linux, use these string values: ^ or ^mnt or ^boot or similar, where the ^ character represents the / character found in Linux file systems. The ^ character must be URL encoded as %5e for input.

Linux example:

This example shows the placeholder ^ encoded on a Linux system.

  • Linux file system name: /dev/xvda
  • Displayed in API output: name=System/Disk/^dev^xvda
  • Encoded for API input:

    names[]=System/Disk/%5Edev%5Exvda

To determine the disks available on a server, use a command similar to this:

curl -X GET 'https://api.newrelic.com/v2/servers/${SERVER_ID}/metrics.json' \
     -H 'X-Api-Key:${API_KEY}' -i \
     -d 'name=System/Filesystem' 

This will return the metric names for the file systems detected on your host.

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 support.newrelic.com.