New Relic Now Start training on Intelligent Observability February 25th.
Save your seat.

If you’re one of the millions of Windows admins, you likely know that Hyper-V is a great Windows utility for creating and managing virtual machines.

Microsoft Hyper-V provides a virtualized computing environment that’s widely used to build public, private, and hybrid clouds. Hyper-V is highly scalable and supports a number of popular operating systems, including Red Hat Enterprise Linux, Debian, Oracle Linux, Ubuntu, and FreeBSD. It also allows you to configure failover clusters to ensure full redundancy.

In this post, we’ll cover how to use New Relic Infrastructure and an on-host integration (OHI) to monitor key metrics from Hyper-V:

New Relic provides the WMI OHI as an open source add-on for our New Relic Infrastructure agent. (See the nri-perfmon repo for details.)

Windows components used to monitor Hyper-V

The following tools are used to monitor Hyper-V and will serve as building blocks for integrating with New Relic.

Windows performance counters

Windows performance counters allow you to analyze the performance data provided by applications, services, and drivers. For example, you can use performance counters to track your system's processor utilization or to determine system bottlenecks and fine-tune application performance.

Microsoft provides extensive documentation on available performance counters.

Microsoft Windows Management Instrumentation (WMI)

Windows WMI is the infrastructure for management data and operations on Windows-based operating systems. You can write WMI scripts or applications to automate administrative tasks on remote computers, but WMI also supplies management data to other parts of the operating system and products such as Windows Remote Management (WinRM).

New Relic collects data from Hyper-V servers by querying the WMI interface on those servers for performance counter data.

A note about Monitoring Hyper-V hosts in Azure or Azure Stack: Microsoft Azure uses a customized version of Hyper-V, known as the Microsoft Azure Hypervisor to provide virtualization of Azure services, and Azure Stack is a hybrid cloud computing solution that runs on the Azure cloud platform. Microsoft doesn’t allow access to Hyper-V hosts in Azure or Azure Stack. However, New Relic does provide a number of Azure integrations you can use to monitor Azure services.

Key metrics to monitor in Hyper-V

To monitor Hyper-V with confidence, we recommend gathering, at minimum, the following performance counters:

Performance counter Definition
Performance counterWmi_hyperv_health_ok DefinitionThis counter represents the number of virtual machines with a health check status of “OK.”
Performance counterWmi_hyperv_health_critical DefinitionThis counter represents the number of virtual machines that have a health check status of “Critical.” If a VM’s health is critical it means some resource, (most likely a disk), has been exhausted or some other unrecoverable error has occurred. In such cases, you should take action to figure out what has happened.
Performance counterVirtualProcessors /(PercentGuestRunTime)(for a given instance of a VM) DefinitionFor a Hyper-V virtual machine, you cannot view the traditional % Processor Time metric to get a good understanding of that VM’s processing. Instead, use this counter to get an equivalent measurement to % Processor Time, but for a specific VM as defined by its instance name.
Performance counterCPUWaitTimePerDispatch DefinitionThis time value should remain under 60,000ms. When an average queue time exceeds 100ms, the VM’s CPU needs more resources .

The New Relic Infrastructure agent will gather the following metric by monitoring the performance counters from the hosts:

  • Memory performance
    • Memory\Available Mbytes
    • Hyper-V Dynamic Memory Balancer (*)\Available Memory
  • Storage performance
    • Disk(disk letter)\Avg. disk sec/Read
    • Disk(disk letter)\Avg. disk sec/Write
    • Disk(disk letter)\Avg. disk read queue length
    • Disk(disk letter)\Avg. disk write queue length
  • Network Performance
    • Network Interface(network adapter name)\Bytes/sec

For more on detecting and resolving bottlenecks in a Microsoft-based virtualized environment, check out their recommendations.

Monitor Hyper-V with the New Relic WMI OHI

Before getting started with the WMI OHI, familiarize yourself with the disclaimer and requirements.

Here’s what the process looks like:

  1. Install the New Relic infrastructure agent on every node in your Hyper-V cluster.
  2. Install New Relic Infrastructure OHI for WMI.
  3. Customize config.json to tell the OHI which performance counters to collect from the Hyper-V environment. Place the config.json file on each of the Hyper-V hosts from which you want to collect data. Here’s an example custom config.json:
    {
    
        "counterlist":[
    
           {
    
              "query":"select HealthCritical, HealthOk from Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary",
    
              "eventname":"Perfmon_HyperVVirtualMachineHealthSummary",
    
              "counters":[
    
                 {
    
                    "attrname":"wmi_hyperv_health_critical",
    
                    "counter":"HealthCritical"
    
                 },
    
                 {
    
                    "attrname":"wmi_hyperv_health_ok",
    
                    "counter":"HealthOk"
    
                 }
    
              ]
    
           },
    
           {
    
              "query":"select * from Win32_PerfRawData_VidPerfProvider_HyperVVMVidPartition",
    
              "eventname":"Perfmon_HyperVVMVidPartition"
    
           },
    
           {
    
              "query":"select * from Win32_PerfRawData_HvStats_HyperVHypervisorRootPartition",
    
              "eventname":"Perfmon_HyperVHypervisorRootPartition"
    
           },
    
           {
    
              "query":"select * from Win32_PerfRawData_HvStats_HyperVHypervisor",
    
              "eventname":"Perfmon_HyperVHypervisor"
    
           },
    
           {
    
              "query":"select * from Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor",
    
              "eventname":"Perfmon_HyperVHypervisorRootVirtualProcessor"
    
           },
    
           {
    
              "query":"select * from Win32_PerfRawData_NvspSwitchStats_HyperVVirtualSwitch",
    
              "eventname":"Perfmon_HyperVVirtualSwitch"
    
           },
    
           {
    
              "query":"select * from Win32_PerfRawData_EthernetPerfProvider_HyperVLegacyNetworkAdapter",
    
              "eventname":"Perfmon_HyperVLegacyNetworkAdapter"
    
           },
    
           {
    
              "query":"select * from Win32_PerfRawData_Counters_HyperVVirtualStorageDevice",
    
              "eventname":"Perfmon_HyperVVirtualStorageDevice"
    
           },
    
           {
    
              "query":"select * from Win32_PerfRawData_NvspNicStats_HyperVVirtualNetworkAdapter",
    
              "eventname":"Perfmon_HyperVVirtualNetworkAdapter"
    
           }
    
        ]
    
     }

    Once it’s installed and running, the New Relic WMI OHI will begin to populate NRDB with custom events, corresponding to the the classes defined in your config.json file:

Visualize your Hyper-V data

Now it's time to create a New Relic One dashboard that can combine data from your WMI OHI and the Infrastructure agent you installed on the Hyper-V hosts.

Here are three example dashboards and the NRQL queries used to create the charts in each:

Dashboard Example 1:

Sample NRQL Queries in Example 1:

  • SELECT average(wmi_hyperv_health_ok) FROM Perfmon_HyperVVirtualMachineHealthSummary facet hostname SINCE 5 minute AGO
  • SELECT count(wmi_hyperv_health_critical) FROM Perfmon_HyperVVirtualMachineHealthSummary facet hostname where wmi_hyperv_health_critical like '%0%' SINCE minutes AGO

Dashboard Example 2:

 

Sample NRQL Queries in Example 2:

  • SELECT average(CPUWaitTimePerDispatch)/average(PercentHypervisorRunTime) FROM Perfmon_HyperVHypervisorRootVirtualProcessor SINCE 30 MINUTES ago facet hostname
  • SELECT average(VirtualProcessors) FROM Perfmon_HyperVHypervisor SINCE 30 MINUTES AGO FACET hostname
  • SELECT average(TotalPages) FROM Perfmon_HyperVHypervisor SINCE 30 MINUTES ago facet hostname
  • SELECT averAGE(LogicalProcessors) FROM Perfmon_HyperVHypervisor SINCE 30 MINUTES AGO FACET hostname

Dashboard Example 3:

Sample NRQL Queries in Example 3:

  • SELECT average(CPUWaitTimePerDispatch)/1000000 FROM Perfmon_HyperVHypervisorRootVirtualProcessor SINCE 5 MINUTES ago facet hostname
  • SELECT count(systemMemoryBytes) FROM Perfmon_HyperVHypervisor FACET systemMemoryBytes SINCE 30 MINUTES AGO TIMESERIES
  • SELECT latest(BytesPersec)/1024000 as 'MB/Sec' FROM Perfmon_HyperVVirtualSwitch SINCE 30 MINUTES AGO facet Name

Conclusion

Monitoring Hyper-V with New Relic:

  • Adds Context. Add context to your Hyper-V metric data when you use it side by side with the rest of your data in the New Relic data platform.
  • Is Flexible. Use the WMI interface to add any Hyper-V metric that you require in your data sets. All data can be easily accessed and visualized in New Relic One dashboards. You can even build your own New Relic One application to curate the data to fit your unique needs.
  • Is Open. The New Relic WMI OHI is built on top of the basic monitoring interface provided natively by Microsoft Windows.

 Want to learn more about how New Relic manages your data? Check out Inside NRDB: A Flexible, Unified Database Built to Scale