mirror of
https://github.com/prometheus-community/windows_exporter
synced 2025-02-05 14:26:53 +00:00
Merge pull request #1034 from gloyka/master
Add Hyper-V Hypervisor Logical Processor metrics
This commit is contained in:
commit
cdeceaeca5
@ -53,6 +53,11 @@ type HyperVCollector struct {
|
||||
LogicalProcessors *prometheus.Desc
|
||||
VirtualProcessors *prometheus.Desc
|
||||
|
||||
// Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor
|
||||
HostLPGuestRunTimePercent *prometheus.Desc
|
||||
HostLPHypervisorRunTimePercent *prometheus.Desc
|
||||
HostLPTotalRunTimePercent *prometheus.Desc
|
||||
|
||||
// Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor
|
||||
HostGuestRunTime *prometheus.Desc
|
||||
HostHypervisorRunTime *prometheus.Desc
|
||||
@ -309,6 +314,27 @@ func NewHyperVCollector() (Collector, error) {
|
||||
|
||||
//
|
||||
|
||||
HostLPGuestRunTimePercent: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, buildSubsystemName("host_lp"), "guest_run_time_percent"),
|
||||
"The percentage of time spent by the processor in guest code",
|
||||
[]string{"core"},
|
||||
nil,
|
||||
),
|
||||
HostLPHypervisorRunTimePercent: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, buildSubsystemName("host_lp"), "hypervisor_run_time_percent"),
|
||||
"The percentage of time spent by the processor in hypervisor code",
|
||||
[]string{"core"},
|
||||
nil,
|
||||
),
|
||||
HostLPTotalRunTimePercent: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, buildSubsystemName("host_lp"), "total_run_time_percent"),
|
||||
"The percentage of time spent by the processor in guest and hypervisor code",
|
||||
[]string{"core"},
|
||||
nil,
|
||||
),
|
||||
|
||||
//
|
||||
|
||||
HostGuestRunTime: prometheus.NewDesc(
|
||||
prometheus.BuildFQName(Namespace, buildSubsystemName("host_cpu"), "guest_run_time"),
|
||||
"The time spent by the virtual processor in guest code",
|
||||
@ -694,6 +720,11 @@ func (c *HyperVCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metri
|
||||
return err
|
||||
}
|
||||
|
||||
if desc, err := c.collectHostLPUsage(ch); err != nil {
|
||||
log.Error("failed collecting hyperV host logical processors metrics:", desc, err)
|
||||
return err
|
||||
}
|
||||
|
||||
if desc, err := c.collectHostCpuUsage(ch); err != nil {
|
||||
log.Error("failed collecting hyperV host CPU metrics:", desc, err)
|
||||
return err
|
||||
@ -999,6 +1030,59 @@ func (c *HyperVCollector) collectVmProcessor(ch chan<- prometheus.Metric) (*prom
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor ...
|
||||
type Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor struct {
|
||||
Name string
|
||||
PercentGuestRunTime uint64
|
||||
PercentHypervisorRunTime uint64
|
||||
PercentTotalRunTime uint
|
||||
}
|
||||
|
||||
func (c *HyperVCollector) collectHostLPUsage(ch chan<- prometheus.Metric) (*prometheus.Desc, error) {
|
||||
var dst []Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor
|
||||
q := queryAll(&dst)
|
||||
if err := wmi.Query(q, &dst); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, obj := range dst {
|
||||
if strings.Contains(obj.Name, "_Total") {
|
||||
continue
|
||||
}
|
||||
// The name format is Hv LP <core id>
|
||||
parts := strings.Split(obj.Name, " ")
|
||||
if len(parts) != 3 {
|
||||
log.Warnf("Unexpected format of Name in collectHostLPUsage: %q", obj.Name)
|
||||
continue
|
||||
}
|
||||
coreId := parts[2]
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.HostLPGuestRunTimePercent,
|
||||
prometheus.GaugeValue,
|
||||
float64(obj.PercentGuestRunTime),
|
||||
coreId,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.HostLPHypervisorRunTimePercent,
|
||||
prometheus.GaugeValue,
|
||||
float64(obj.PercentHypervisorRunTime),
|
||||
coreId,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.HostLPTotalRunTimePercent,
|
||||
prometheus.GaugeValue,
|
||||
float64(obj.PercentTotalRunTime),
|
||||
coreId,
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor ...
|
||||
type Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor struct {
|
||||
Name string
|
||||
|
@ -5,7 +5,7 @@ The hyperv collector exposes metrics about the Hyper-V hypervisor
|
||||
|||
|
||||
-|-
|
||||
Metric name prefix | `hyperv`
|
||||
Classes | `Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary`<br/>`Win32_PerfRawData_VidPerfProvider_HyperVVMVidPartition`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorRootPartition`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor`<br/>`Win32_PerfRawData_NvspSwitchStats_HyperVVirtualSwitch`<br/>`Win32_PerfRawData_EthernetPerfProvider_HyperVLegacyNetworkAdapter`<br/>`Win32_PerfRawData_Counters_HyperVVirtualStorageDevice`<br/>`Win32_PerfRawData_NvspNicStats_HyperVVirtualNetworkAdapter`
|
||||
Classes | `Win32_PerfRawData_VmmsVirtualMachineStats_HyperVVirtualMachineHealthSummary`<br/>`Win32_PerfRawData_VidPerfProvider_HyperVVMVidPartition`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorRootPartition`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorLogicalProcessor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor`<br/>`Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor`<br/>`Win32_PerfRawData_NvspSwitchStats_HyperVVirtualSwitch`<br/>`Win32_PerfRawData_EthernetPerfProvider_HyperVLegacyNetworkAdapter`<br/>`Win32_PerfRawData_Counters_HyperVVirtualStorageDevice`<br/>`Win32_PerfRawData_NvspNicStats_HyperVVirtualNetworkAdapter`
|
||||
Enabled by default? | No
|
||||
|
||||
## Flags
|
||||
@ -44,6 +44,9 @@ Name | Description | Type | Labels
|
||||
`windows_hyperv_root_partition_virtual_tlb_pages` | _Not yet documented_ | counter | None
|
||||
`windows_hyperv_hypervisor_virtual_processors` | _Not yet documented_ | counter | None
|
||||
`windows_hyperv_hypervisor_logical_processors` | _Not yet documented_ | counter | None
|
||||
`windows_hyperv_host_lp_guest_run_time_percent` | _Not yet documented_ | counter | `core`
|
||||
`windows_hyperv_host_lp_hypervisor_run_time_percent` | _Not yet documented_ | counter | `core`
|
||||
`windows_hyperv_host_lp_total_run_time_percent` | _Not yet documented_ | counter | `core`
|
||||
`windows_hyperv_host_cpu_guest_run_time` | _Not yet documented_ | counter | `core`
|
||||
`windows_hyperv_host_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `core`
|
||||
`windows_hyperv_host_cpu_remote_run_time` | _Not yet documented_ | counter | `core`
|
||||
@ -118,6 +121,10 @@ Percent of physical CPU resources by the hosts themselves (on all monitored host
|
||||
```
|
||||
(sum by (instance)(rate(windows_hyperv_host_cpu_total_run_time{}[1m]))) / sum by (instance)(windows_cs_logical_processors{}) / 100000
|
||||
```
|
||||
Percent of physical CPU resources by the hypervisor (on all monitored hosts)
|
||||
```
|
||||
(sum by (instance)(rate(windows_hyperv_host_lp_total_run_time_percent{}[1m]))) / sum by (instance)(windows_hyperv_hypervisor_logical_processors{}) / 100000
|
||||
```
|
||||
|
||||
## Alerting examples
|
||||
_This collector does not yet have alerting examples, we would appreciate your help adding them!_
|
||||
|
Loading…
Reference in New Issue
Block a user