Expose host/vm powerered state metrics - #42
Conversation
|
I wondered this or add a label to vm/host_info metrics - my idea behind these were to host all non-metric information about particular vSphere object... but may be cumbersome to use in dashboards if only a label... |
|
Thanks for the feedback. I considered adding this as labels on vm_info/host_info, but I chose explicit 0/1 metrics because they are easier to use in PromQL, dashboards and alerts. For example:
With only labels on *_info metrics, users would need to filter on label values, which is useful for metadata but less convenient for alerting and numeric aggregation. That said, I agree that power_state/connectivity are also descriptive information. So i let this PR on draft some time (and will rebase it) to see if there are any more feedback. I can still:
|
|
Great PR @Zophar78. Thank you! |
ffe788d to
1c76efc
Compare
|
Ok PR is now ready for review/merge. |
| vmLabels := map[string]string{ | ||
| "vmmo": vm.Self.Value, | ||
| "vm": vm.Summary.Config.Name, | ||
| "hostmo": vm.Runtime.Host.Value, |
There was a problem hiding this comment.
Runtime.Host can be nil per Broadcom's vSphere API docs when the VM is not running and is not assigned to run on a particular host.
There was a problem hiding this comment.
I'll take a look on this one
There was a problem hiding this comment.
Thanks for the catch, you were right. I’ve pushed a fix to handle Runtime.Host being nil for powered-off/unassigned VMs, based on the VirtualMachineRuntimeInfo docs.
This PR adds explicit state metrics for VMware Hosts and VMs so powered-off entities are still visible in Prometheus.
What’s included:
Solve #30