Get host networking data (v2)

Data received and transmitted by the server network interfaces appear in the New Relic Servers user interface:

  • On your host's Overview page when you mouse over a data point on the Network I/O (Mb/s) chart
  • On a specific network interface's Bandwidth chart on the Network page

Here are examples of how to use the New Relic REST API (v2) to obtain the data being received or transmitted. Be sure to replace the ${SERVER_ID} placeholder with your specific server ID.

When acquiring data, the values returned will be affected by the time range you specify and the way the data is stored. For more information, see Extracting metric timeslice data.

Identify system network rates

To obtain the amount of data transferred by a host, use these metric names:

System/Network/${INTERFACE}/Transmitted/bytes/sec
System/Network/${INTERFACE}/Received/bytes/sec

To obtain the number of packets being transferred by a host, use these metric names:

System/Network/${INTERFACE}/Transmitted/packets/sec
System/Network/${INTERFACE}/Received/packets/sec

For ${INTERFACE}, use either of these interface values:

  • All (for the host's Overview or aggregate chart)
  • The name of the individual network interface from the Network page; for example, eth0, eth2, etc.

The metric value required for each is per_second.

Get average data transferred (all interfaces)

To get the average data received and transmitted over a specified time range for all of the network interfaces on the host, use a command similar to this:

curl -X GET "https://api.newrelic.com/v2/servers/${SERVER_ID}/metrics/data.xml" \
     -H "X-Api-Key:${API_KEY}" -i \
     -d 'names[]=System/Network/All/Received/bytes/sec&names[]=System/Network/All/Transmitted/bytes/sec&values[]=per_second&from=2014-09-08T16:04:00+00:00&to=2014-09-08T16:34:00+00:00&summarize=true' 

To obtain the data for each time increment in the range, change the summarize value from true to false, or remove &summarize=true entirely.

Get average data transferred (single interface)

To get the average data received and transmitted over a specified time range for a single network interface on the host, use a command similar to the following. Be sure to replace ${INTERFACE} with a specific interface name (for example, eth0). Do not use All.

curl -X GET "https://api.newrelic.com/v2/servers/${SERVER_ID}/metrics/data.xml" \
     -H "X-Api-Key:${API_KEY}" -i \
     -d 'names[]=System/Network/${INTERFACE}/Received/bytes/sec&names[]=System/Network/${INTERFACE}/Transmitted/bytes/sec&values[]=per_second&from=2014-09-08T16:04:00+00:00&to=2014-09-08T16:34:00+00:00&summarize=true' 

Convert bytes (API) to megabits (UI)

Data stored and returned by the API is in bytes/sec, but it appears on the host's Overview page as megabits/sec (Mb/s, based on 1024 being a kilobyte). To match the values obtained from your API calls with the values that appear on your page, use this calculation:

megabits/sec = (<bytes/sec> * 8) / (1024)**2

Get average packets transferred

To get the average number of packets received and transmitted over a specified time range for a single network interface on the host, use a command similar to this:

curl -X GET 'https://api.newrelic.com/v2/servers/${SERVER_ID}/metrics/data.xml' \
     -H 'X-Api-Key:${API_KEY}' -i \
     -d 'names[]=System/Network/${INTERFACE}/Received/packets/sec&names[]=System/Network/${INTERFACE}/Transmitted/packets/sec&values[]=per_second&from=2014-04-08T13:40:00+00:00&to=2014-04-08T13:45:00+00:00&summarize=true'

For more help

Additional documentation resources include:

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.