Skip to content

Commit

Permalink
Added warning for resource metrics not returned by HMC
Browse files Browse the repository at this point in the history
Details:

* Resource-based metrics defined in the metric definition file but not
  returned by the HMC as a resource property (e.g. because the HMC is too
  old) now cause a Python warning to be printed.

* Added the respective 'if' conditionals to the default metric definition
  file for such HMC or SE version dependent resource metrics, to not have
  that warning show up when using the default metric definition file.

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Nov 28, 2023
1 parent cb6d261 commit a7e0da3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
7 changes: 7 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ Released: not yet

**Cleanup:**

* Resource-based metrics defined in the metric definition file but not
returned by the HMC as a resource property (e.g. because the HMC is too
old) now cause a Python warning to be printed. Added the respective 'if'
conditionals to the default metric definition file for such HMC or SE version
dependent resource metrics, to not have that warning show up when using the
default metric definition file.

**Known issues:**

* See `list of open issues`_.
Expand Down
19 changes: 11 additions & 8 deletions examples/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ metric_groups:
resource: cpc.partition
prefix: partition
fetch: true
if: "hmc_version>='2.13.1'"
labels:
- name: cpc
value: "resource_obj.manager.parent.name"
Expand All @@ -146,6 +147,7 @@ metric_groups:
resource: console.storagegroup
prefix: storagegroup
fetch: true
if: "hmc_version>='2.14.1'"
labels:
- name: cpc
value: "uri2resource(resource_obj.properties['cpc-uri']).name"
Expand All @@ -157,6 +159,7 @@ metric_groups:
resource: console.storagevolume
prefix: storagevolume
fetch: true
if: "hmc_version>='2.14.1'"
labels:
- name: cpc
value: "uri2resource(resource_obj.manager.parent.properties['cpc-uri']).name"
Expand Down Expand Up @@ -1479,35 +1482,35 @@ metrics:
exporter_name: spare_processor_count
exporter_desc: Number of spare processors of all processor types
- property_name: storage-total-installed
# since HMC/SE version 2.13.1
if: "se_version>='2.13.1'"
exporter_name: total_memory_mib
exporter_desc: Total amount of installed memory, in MiB
- property_name: storage-hardware-system-area
# since HMC/SE version 2.13.1
if: "se_version>='2.13.1'"
exporter_name: hsa_memory_mib
exporter_desc: Amount of memory reserved for the base hardware system area (HSA), in MiB
- property_name: storage-customer
# since HMC/SE version 2.13.1
if: "se_version>='2.13.1'"
exporter_name: partition_memory_mib
exporter_desc: Amount of memory for use by partitions, in MiB
- property_name: storage-customer-central
# since HMC/SE version 2.13.1
if: "se_version>='2.13.1'"
exporter_name: partition_central_memory_mib
exporter_desc: Amount of memory allocated as central storage across the active partitions, in MiB
- property_name: storage-customer-expanded
# since HMC/SE version 2.13.1
if: "se_version>='2.13.1'"
exporter_name: partition_expanded_memory_mib
exporter_desc: Amount of memory allocated as expanded storage across the active partitions, in MiB
- property_name: storage-customer-available
# since HMC/SE version 2.13.1
if: "se_version>='2.13.1'"
exporter_name: available_memory_mib
exporter_desc: Amount of memory not allocated to active partitions, in MiB
- property_name: storage-vfm-increment-size
# since HMC/SE version 2.14.0
if: "se_version>='2.14.0'"
exporter_name: vfm_increment_gib
exporter_desc: Increment size of IBM Virtual Flash Memory (VFM), in GiB
- property_name: storage-vfm-total
# since HMC/SE version 2.14.0
if: "se_version>='2.14.0'"
exporter_name: total_vfm_gib
exporter_desc: Total amount of installed IBM Virtual Flash Memory (VFM), in GiB
- properties_expression: "{'active': 0, 'operating': 0, 'degraded': 1, 'service-required': 2, 'service': 10, 'exceptions': 11, 'not-communicating': 12, 'status-check': 13, 'not-operating': 14, 'no-powerstatus': 15}.get(properties.status, 99)"
Expand Down
13 changes: 11 additions & 2 deletions zhmc_prometheus_exporter/zhmc_prometheus_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1313,8 +1313,17 @@ def build_family_objects_res(
try:
metric_value = resource.properties[prop_name]
except KeyError:
# Skip resource properties that do not exist on older
# CPC/HMC versions.
if cpc:
res_str = " for CPC '{}'".format(cpc.name)
else:
res_str = ""
warnings.warn(
"Skipping metric with exporter name '{}' in "
"resource metric group '{}' in metric definition "
"file {}, because its resource property '{}' is "
"not returned by the HMC{}".
format(exporter_name, metric_group,
metrics_filename, prop_name, res_str))
continue
else:
prop_expr = yaml_metric.get('properties_expression', None)
Expand Down

0 comments on commit a7e0da3

Please sign in to comment.