Get available and used disk space (v2)


New Relic Servers is no longer available. For infrastructure monitoring, please use New Relic Infrastructure. For how to switch to Infrastructure from Servers, see the transition guide.

Available and used disk space appears on the New Relic Servers Disks page on the bottom Space usage chart. While the displayed value is percentage used, you can view the available and used space when you hover over the chart.

This is an example of how to use the New Relic REST API (v2) to find available and used disk space for a specific server ID and API key. The default time range 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 space available and used

To obtain the disk space for a specific disk for the selected time period, use the metric name

System/Disk/${DISK_NAME}/Used/bytes. For example:

curl -X GET "${APPID}/metrics/data.xml"\
    -H "X-Api-Key:${API_KEY}" -i\
    - d'names[]=System/Filesystem/${DISK_NAME/Used/bytes&values[]=average_response_time&values[]=average_exclusive_time&from=2014-09-17T21:00:00+00:00&to=2014-09-24T21:00:00+00:00&summarize=true'

Metric values include:

  • Total disk space used, indicated by average_response_time
  • Capacity of the disk, indicated by average_exclusive_time

Currently the returned values can be a factor of 1000 greater than expected.

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:


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

curl -X GET '${APPID}/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.

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

Data stored and returned by the API for disk space is in bytes, but it appears on the New Relic Servers Disks page in terms of gigabytes (based on 1024 being a kilobyte). To match the values obtained from your API calls with the values that appear in the UI, use these calculations:

Total disk space used = <average_response_time> / (1024)**2
Capacity of the disk = <average_exclusive_time>/ (1024)**2
Percent disk used = (<average_response_time> / <average_exclusive_time>) * 100

Currently the returned values can be a factor of 1000 greater than expected.

For more help

New Relic Servers is unavailable as of May 15, 2018. For more information: