Skip to content

Commit

Permalink
Change template status as labels in pve_guest_info
Browse files Browse the repository at this point in the history
  • Loading branch information
tosabyte committed Jan 3, 2024
1 parent 6c0fae5 commit 17c9577
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PVE_USER=prometheus@pve
PVE_TOKEN_NAME=prompve-scraper
PVE_TOKEN_VALUE=d0ba3361-daa3-4f88-aa91-747c0f8f626a
12 changes: 4 additions & 8 deletions src/pve_exporter/collector/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,13 @@ def collect(self): # pylint: disable=missing-docstring
'pve_storage_shared',
'Whether or not the storage is shared among cluster nodes',
labels=['id']),
'template': GaugeMetricFamily(
'pve_template',
'Whether or not the VM/CT is template',
labels=['id']),
}

info_metrics = {
'guest': GaugeMetricFamily(
'pve_guest_info',
'VM/CT info',
labels=['id', 'node', 'name', 'type']),
labels=['id', 'node', 'name', 'type', 'template']),
'storage': GaugeMetricFamily(
'pve_storage_info',
'Storage info',
Expand All @@ -222,11 +218,11 @@ def collect(self): # pylint: disable=missing-docstring

info_lookup = {
'lxc': {
'labels': ['id', 'node', 'name', 'type'],
'labels': ['id', 'node', 'name', 'type', 'template'],
'gauge': info_metrics['guest'],
},
'qemu': {
'labels': ['id', 'node', 'name', 'type'],
'labels': ['id', 'node', 'name', 'type', 'template'],
'gauge': info_metrics['guest'],
},
'storage': {
Expand All @@ -239,7 +235,7 @@ def collect(self): # pylint: disable=missing-docstring
restype = resource['type']

if restype in info_lookup:
label_values = [resource.get(key, '') for key in info_lookup[restype]['labels']]
label_values = [str(resource.get(key, '')) for key in info_lookup[restype]['labels']]
info_lookup[restype]['gauge'].add_metric(label_values, 1)

label_values = [resource['id']]
Expand Down

0 comments on commit 17c9577

Please sign in to comment.