Add VmSourceVRA label and resolve VRA names for VM metrics

- Add VmSourceVRA to _VM_LABELS, populated from vm['OwningHostName']
  resolved to a VRA name via a host→VRA lookup built from zvm.vras()
- VmRecoveryVRA now also resolves to the actual VRA name (e.g.
  Z-VRA-192.168.50.21) instead of the raw ESXi host IP
- Cloud-target VPGs (Azure/AWS) correctly emit VmRecoveryVRA="" since
  there is no local VRA on the recovery side
- Bump version to 3.1.0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 11:39:35 -05:00
parent d058b9fcbd
commit 7a45a9c49a
2 changed files with 10 additions and 3 deletions
+9 -2
View File
@@ -94,7 +94,7 @@ g_ds_zerto_appliances_used = Gauge('datastore_usage_zerto_appliances_used
g_ds_zerto_appliances_provisioned = Gauge('datastore_usage_zerto_appliances_provisionedinbytes', 'Datastore Zerto Appliances Provisioned In Bytes', _DS_LABELS)
# VM metrics (GetDataFunc - VMs section)
_VM_LABELS = ['VmIdentifier', 'VmName', 'VmRecoveryVRA', 'VmPriority', 'SiteIdentifier', 'VpgName', 'SiteName']
_VM_LABELS = ['VmIdentifier', 'VmName', 'VmSourceVRA', 'VmRecoveryVRA', 'VmPriority', 'SiteIdentifier', 'VpgName', 'SiteName']
g_vm_actualrpo = Gauge('vm_actualrpo', 'VM Actual RPO', _VM_LABELS)
g_vm_throughput = Gauge('vm_throughput_in_mb', 'VM Throughput In MB', _VM_LABELS)
g_vm_iops = Gauge('vm_iops', 'VM IOPs', _VM_LABELS)
@@ -337,6 +337,12 @@ def GetDataFunc(zvm_instance):
else:
log.debug("No Datastores Found")
## Build host → VRA name lookup for source/recovery VRA labels
host_to_vra = {}
vras_for_lookup = zvm.vras()
if vras_for_lookup:
host_to_vra = {v['HostDisplayName']: v['VraName'] for v in vras_for_lookup}
## VMs API
log.debug("Getting VMs API")
vms_json = zvm.vms()
@@ -355,7 +361,8 @@ def GetDataFunc(zvm_instance):
lbl = dict(
VmIdentifier=str(vm['VmIdentifier']),
VmName=str(vm['VmName']),
VmRecoveryVRA=str(vm["RecoveryHostName"]),
VmSourceVRA=host_to_vra.get(str(vm['OwningHostName']), ''),
VmRecoveryVRA=host_to_vra.get(str(vm['RecoveryHostName']), ''),
VmPriority=str(vm['Priority']),
SiteIdentifier=str(siteId),
VpgName=str(vm['VpgName']),
+1 -1
View File
@@ -1,5 +1,5 @@
# version.py
VERSION = "3.0.0"
VERSION = "3.1.0"
def main():
# Put your main program code here