diff --git a/docs/changes.rst b/docs/changes.rst index 8142af8b..e4d1c8a1 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -118,6 +118,12 @@ 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 manages + older SE versions) 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. + **Known issues:** * See `list of open issues`_. diff --git a/examples/metrics.yaml b/examples/metrics.yaml index b8dd13eb..b0802f6d 100644 --- a/examples/metrics.yaml +++ b/examples/metrics.yaml @@ -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" @@ -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" @@ -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" @@ -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)" diff --git a/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py b/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py index 5172fa61..cf59fb82 100755 --- a/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py +++ b/zhmc_prometheus_exporter/zhmc_prometheus_exporter.py @@ -1320,8 +1320,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)