hyperv: Add host CPU ratio metric for monitoring CPU allocation#2288
hyperv: Add host CPU ratio metric for monitoring CPU allocation#2288Dominik-esb wants to merge 4 commits intoprometheus-community:masterfrom
Conversation
This adds a new metric windows_hyperv_host_cpu_ratio that shows the ratio of physical logical CPU cores to virtual cores assigned to all VMs on the Hyper-V host. The metric helps monitor CPU oversubscription/undersubscription on the hypervisor. A ratio > 1 indicates undersubscription, while < 1 indicates oversubscription. Signed-off-by: EisenbergD <dominik.eisenberg@beiersdorf.com>
|
Hi @jkroepke, could you have a look at this idea? I’m trying to calculate the ratio between logical CPU cores in a cluster and the total v-cores assigned to VMs (e.g. 100 physical cores / 300 v-cores = 3:1). This isn’t straightforward, as there is no per-VM metric that exposes the configured core count. Currently, I’m approximating the number of virtual cores using: This works to some extent, but it doesn’t feel ideal. While testing, I also noticed that some VMs are missing, causing the v-core count per cluster to differ from what Hyper-V reports. In multiple clusters, 2–6 VMs are missing. This is likely a separate issue, but it directly affects the CPU ratio calculation. Even if the VM counting issue can be resolved, having a reliable logical-core-to-v-core ratio per host could be useful. As an alternative it might also be worth considering exposing the configured core count per VM as a dedicated metric |
Sometimes, I run additional Win32 APIs calls to gain such informations. Generally, I like to avoid WMI as much as possible. As I know, the Host Compute Service API can be used to query such information. The Host Compute Service API is used by the container collector. |
Signed-off-by: EisenbergD <dominik.eisenberg@beiersdorf.com>
…ows_exporter into add-vm-cpu-ration-metric
… metric Signed-off-by: EisenbergD <dominik.eisenberg@beiersdorf.com>
Which issue this PR fixes
(optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close that issue when PR gets merged):N/A - This is a feature enhancement
Special notes for your reviewer
Hyper-V Hypervisor Logical ProcessorandHyper-V Hypervisor Virtual Processor) to calculate the ratioParticularly user-facing changes
windows_hyperv_host_cpu_ratiowithhostlabelhost(enabled by default in hyperv collector)Checklist
Complete these before marking the PR as
ready to review: