Skip to content

Commit

Permalink
Add UUID and Instance UUID in VM labels
Browse files Browse the repository at this point in the history
  • Loading branch information
a-belhadj committed Dec 7, 2022
1 parent b441656 commit 48ee064
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions vmware_exporter/vmware_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def __init__(

# label names and ammount will be needed later to insert labels from custom attributes
self._labelNames = {
'vms': ['vm_name', 'ds_name', 'host_name', 'dc_name', 'cluster_name'],
'vm_perf': ['vm_name', 'ds_name', 'host_name', 'dc_name', 'cluster_name'],
'vmguests': ['vm_name', 'ds_name', 'host_name', 'dc_name', 'cluster_name'],
'vms': ['vm_name', 'ds_name', 'host_name', 'dc_name', 'cluster_name', 'uuid', 'instance_uuid'],
'vm_perf': ['vm_name', 'ds_name', 'host_name', 'dc_name', 'cluster_name', 'uuid', 'instance_uuid'],
'vmguests': ['vm_name', 'ds_name', 'host_name', 'dc_name', 'cluster_name', 'uuid', 'instance_uuid'],
'snapshots': ['vm_name', 'ds_name', 'host_name', 'dc_name', 'cluster_name'],
'datastores': ['ds_name', 'dc_name', 'ds_cluster'],
'hosts': ['host_name', 'dc_name', 'cluster_name'],
Expand Down Expand Up @@ -738,6 +738,8 @@ def vm_inventory(self):
'runtime.host',
'parent',
'summary.config.vmPathName',
'summary.config.uuid',
'summary.config.instanceUuid',
]

if self.collect_only['vms'] is True:
Expand Down Expand Up @@ -1104,6 +1106,15 @@ def vm_labels(self):
if host_moid in host_labels:
labels[moid] = labels[moid] + host_labels[host_moid]

if 'summary.config.uuid' in row:
labels[moid] += [row['summary.config.uuid']]
else:
labels[moid] += ["no_uuid"]
if 'summary.config.instanceUuid' in row:
labels[moid] += [row['summary.config.instanceUuid']]
else:
labels[moid] += ["no_instanceUuid"]

"""
this code was in vm_inventory before
but I have the feeling it is best placed here where
Expand Down

0 comments on commit 48ee064

Please sign in to comment.