Enable resource metering in Hyper-V to collect usage data

Easily monitor resource utilization for your Hyper-V VMs by first enabling the resource metering feature and then collecting data with a few PowerShell commands.

The Measure-VM command provides you with data about processor and memory usage, as well as network traffic for Hyper-V VMs, but you must enable resource metering before you can use the command to collect data.

To enable resource metering for a Hyper-V VM, execute Enable-VMResourceMetering -VMName SQLVM. Once resource metering is enabled, the Hyper-V host starts collecting data for the VM and provides measured data.

The command above enables resource metering for all resource types, but the command below enables resource metering just for memory:

Enable-VMResourceMetering -ResourcePoolName TestMemoryPool -ResourcePoolType Memory

Both of these commands enable resource metering, but the first command collects data and stores it in the default Hyper-V resource pool, and the second command stores data in a resource pool that you have specified -- TestMemoryPool. To collect data for the first command, use the Measure-VM PowerShell cmdlet, and then use the Measure-VMResourcePool PowerShell cmdlet to collect data from the resource pool.

To collect data using the Measure-VM cmdlet, execute Measure-VM -VMName SQLVM. The report includes information about virtual storage, average virtual processor usage, average memory usage and so on, as shown in Figure A.

Measure-VM output
Figure A. Output of Measure-VM PowerShell cmdlet

If you must enable resource metering for specific resource types, such as processors, memory and virtual hard drives (VHDs), execute this command:

Enable-VMResourceMetering -Name TestPool -ResourcePoolType@("Processor","VHD","Memory")

To report data collected from a resource pool, execute Measure-VMResourcePool -Name TestPool. This command will display measured data for processors, VHDs and memory because TestPool is configured to monitor only those specific resources.

Dig Deeper on IT systems management and monitoring

Software Quality
App Architecture
Cloud Computing
Data Center