Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vmware_exporter.py to add unit labels #275

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions vmware_exporter/vmware_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ def __init__(
# label names and ammount will be needed later to insert labels from custom attributes
self._labelNames = {
'vms': ['vm_name', 'host_name', 'dc_name', 'cluster_name'],
'vm_perf': ['vm_name', 'host_name', 'dc_name', 'cluster_name'],
'vm_perf': ['vm_name', 'host_name', 'dc_name', 'cluster_name', 'unit'],
'vmguests': ['vm_name', 'host_name', 'dc_name', 'cluster_name'],
'snapshots': ['vm_name', 'host_name', 'dc_name', 'cluster_name'],
'datastores': ['ds_name', 'dc_name', 'ds_cluster'],
'hosts': ['host_name', 'dc_name', 'cluster_name'],
'host_perf': ['host_name', 'dc_name', 'cluster_name'],
'host_perf': ['host_name', 'dc_name', 'cluster_name', 'unit'],
}

# if tags are gonna be fetched 'tags' will be a label too
Expand Down Expand Up @@ -1387,7 +1387,7 @@ def _vmware_get_vm_perf_manager_metrics(self, vm_metrics):
for ent in results:
for metric in ent.value:
vm_metrics[metric_names[metric.id.counterId]].add_metric(
labels[ent.entity._moId],
labels[ent.entity._moId] + [content.perfManager.QueryPerfCounter([metric.id.counterId])[0].unitInfo.label],
float(sum(metric.value)),
)

Expand Down Expand Up @@ -1472,7 +1472,7 @@ def _vmware_get_host_perf_manager_metrics(self, host_metrics):
for ent in results:
for metric in ent.value:
host_metrics[metric_names[metric.id.counterId]].add_metric(
labels[ent.entity._moId],
labels[ent.entity._moId] + [content.perfManager.QueryPerfCounter([metric.id.counterId])[0].unitInfo.label],
float(sum(metric.value)),
)

Expand Down