From e2b48497f4b507d53ba77dd8747ee9b5d2771b71 Mon Sep 17 00:00:00 2001 From: Yuriy Ostapenko Date: Tue, 30 May 2023 16:53:05 +0200 Subject: [PATCH 1/2] Add Hyper-V CPUWaitTimePerDispatch collection Signed-off-by: Yuriy Ostapenko --- collector/hyperv.go | 45 +++++++++++++++++++++++++++++++++------- docs/collector.hyperv.md | 2 ++ 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/collector/hyperv.go b/collector/hyperv.go index 796898bb..d2208f36 100644 --- a/collector/hyperv.go +++ b/collector/hyperv.go @@ -59,16 +59,18 @@ type HyperVCollector struct { HostLPTotalRunTimePercent *prometheus.Desc // Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor - HostGuestRunTime *prometheus.Desc - HostHypervisorRunTime *prometheus.Desc - HostRemoteRunTime *prometheus.Desc - HostTotalRunTime *prometheus.Desc + HostGuestRunTime *prometheus.Desc + HostHypervisorRunTime *prometheus.Desc + HostRemoteRunTime *prometheus.Desc + HostTotalRunTime *prometheus.Desc + HostCPUWaitTimePerDispatch *prometheus.Desc // Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor - VMGuestRunTime *prometheus.Desc - VMHypervisorRunTime *prometheus.Desc - VMRemoteRunTime *prometheus.Desc - VMTotalRunTime *prometheus.Desc + VMGuestRunTime *prometheus.Desc + VMHypervisorRunTime *prometheus.Desc + VMRemoteRunTime *prometheus.Desc + VMTotalRunTime *prometheus.Desc + VMCPUWaitTimePerDispatch *prometheus.Desc // Win32_PerfRawData_NvspSwitchStats_HyperVVirtualSwitch BroadcastPacketsReceived *prometheus.Desc @@ -362,6 +364,12 @@ func newHyperVCollector(logger log.Logger) (Collector, error) { []string{"core"}, nil, ), + HostCPUWaitTimePerDispatch: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, buildSubsystemName("host_cpu"), "wait_time_per_dispatch"), + "Time in nanoseconds waiting for a virtual processor to be dispatched onto a logical processor", + []string{"core"}, + nil, + ), // @@ -389,6 +397,12 @@ func newHyperVCollector(logger log.Logger) (Collector, error) { []string{"vm", "core"}, nil, ), + VMCPUWaitTimePerDispatch: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, buildSubsystemName("vm_cpu"), "wait_time_per_dispatch"), + "Time in nanoseconds waiting for a virtual processor to be dispatched onto a logical processor", + []string{"vm", "core"}, + nil, + ), // BroadcastPacketsReceived: prometheus.NewDesc( @@ -1093,6 +1107,7 @@ type Win32_PerfRawData_HvStats_HyperVHypervisorRootVirtualProcessor struct { PercentHypervisorRunTime uint64 PercentRemoteRunTime uint64 PercentTotalRunTime uint64 + CPUWaitTimePerDispatch uint64 } func (c *HyperVCollector) collectHostCpuUsage(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { @@ -1142,6 +1157,12 @@ func (c *HyperVCollector) collectHostCpuUsage(ch chan<- prometheus.Metric) (*pro coreId, ) + ch <- prometheus.MustNewConstMetric( + c.HostCPUWaitTimePerDispatch, + prometheus.CounterValue, + float64(obj.CPUWaitTimePerDispatch), + coreId, + ) } return nil, nil @@ -1154,6 +1175,7 @@ type Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor struct { PercentHypervisorRunTime uint64 PercentRemoteRunTime uint64 PercentTotalRunTime uint64 + CPUWaitTimePerDispatch uint64 } func (c *HyperVCollector) collectVmCpuUsage(ch chan<- prometheus.Metric) (*prometheus.Desc, error) { @@ -1209,6 +1231,13 @@ func (c *HyperVCollector) collectVmCpuUsage(ch chan<- prometheus.Metric) (*prome vmName, coreId, ) + ch <- prometheus.MustNewConstMetric( + c.VMCPUWaitTimePerDispatch, + prometheus.CounterValue, + float64(obj.CPUWaitTimePerDispatch), + vmName, coreId, + ) + } return nil, nil diff --git a/docs/collector.hyperv.md b/docs/collector.hyperv.md index b6ebfeb2..a47d2ae3 100644 --- a/docs/collector.hyperv.md +++ b/docs/collector.hyperv.md @@ -51,9 +51,11 @@ Name | Description | Type | Labels `windows_hyperv_host_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `core` `windows_hyperv_host_cpu_remote_run_time` | _Not yet documented_ | counter | `core` `windows_hyperv_host_cpu_total_run_time` | _Not yet documented_ | counter | `core` +`windows_hyperv_host_cpu_wait_time_per_dispatch` | _Not yet documented_ | counter | `core` `windows_hyperv_vm_cpu_guest_run_time` | _Not yet documented_ | counter | `vm`, `core` `windows_hyperv_vm_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `vm`, `core` `windows_hyperv_vm_cpu_remote_run_time` | _Not yet documented_ | counter | `vm`, `core` +`windows_hyperv_vm_cpu_wait_time_per_dispatch` | _Not yet documented_ | counter | `vm`, `core` `windows_hyperv_vm_memory_added_total` | _Not yet documented_ | counter | `vm` `windows_hyperv_vm_memory_pressure_average` | _Not yet documented_ | gauge | `vm` `windows_hyperv_vm_memory_pressure_current` | _Not yet documented_ | counter | `vm` From ca5124fdf90c7c3104b193f76b58c2cff03a35a2 Mon Sep 17 00:00:00 2001 From: Yuriy Ostapenko Date: Tue, 8 Aug 2023 09:57:56 +0200 Subject: [PATCH 2/2] Add _total suffix for counters Signed-off-by: Yuriy Ostapenko --- collector/hyperv.go | 4 ++-- docs/collector.hyperv.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/collector/hyperv.go b/collector/hyperv.go index d2208f36..39fd0d92 100644 --- a/collector/hyperv.go +++ b/collector/hyperv.go @@ -365,7 +365,7 @@ func newHyperVCollector(logger log.Logger) (Collector, error) { nil, ), HostCPUWaitTimePerDispatch: prometheus.NewDesc( - prometheus.BuildFQName(Namespace, buildSubsystemName("host_cpu"), "wait_time_per_dispatch"), + prometheus.BuildFQName(Namespace, buildSubsystemName("host_cpu"), "wait_time_per_dispatch_total"), "Time in nanoseconds waiting for a virtual processor to be dispatched onto a logical processor", []string{"core"}, nil, @@ -398,7 +398,7 @@ func newHyperVCollector(logger log.Logger) (Collector, error) { nil, ), VMCPUWaitTimePerDispatch: prometheus.NewDesc( - prometheus.BuildFQName(Namespace, buildSubsystemName("vm_cpu"), "wait_time_per_dispatch"), + prometheus.BuildFQName(Namespace, buildSubsystemName("vm_cpu"), "wait_time_per_dispatch_total"), "Time in nanoseconds waiting for a virtual processor to be dispatched onto a logical processor", []string{"vm", "core"}, nil, diff --git a/docs/collector.hyperv.md b/docs/collector.hyperv.md index a47d2ae3..0b799e6b 100644 --- a/docs/collector.hyperv.md +++ b/docs/collector.hyperv.md @@ -51,11 +51,11 @@ Name | Description | Type | Labels `windows_hyperv_host_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `core` `windows_hyperv_host_cpu_remote_run_time` | _Not yet documented_ | counter | `core` `windows_hyperv_host_cpu_total_run_time` | _Not yet documented_ | counter | `core` -`windows_hyperv_host_cpu_wait_time_per_dispatch` | _Not yet documented_ | counter | `core` +`windows_hyperv_host_cpu_wait_time_per_dispatch_total` | _Not yet documented_ | counter | `core` `windows_hyperv_vm_cpu_guest_run_time` | _Not yet documented_ | counter | `vm`, `core` `windows_hyperv_vm_cpu_hypervisor_run_time` | _Not yet documented_ | counter | `vm`, `core` `windows_hyperv_vm_cpu_remote_run_time` | _Not yet documented_ | counter | `vm`, `core` -`windows_hyperv_vm_cpu_wait_time_per_dispatch` | _Not yet documented_ | counter | `vm`, `core` +`windows_hyperv_vm_cpu_wait_time_per_dispatch_total` | _Not yet documented_ | counter | `vm`, `core` `windows_hyperv_vm_memory_added_total` | _Not yet documented_ | counter | `vm` `windows_hyperv_vm_memory_pressure_average` | _Not yet documented_ | gauge | `vm` `windows_hyperv_vm_memory_pressure_current` | _Not yet documented_ | counter | `vm`