From: Atul Agarwal Date: Wed, 2 Jun 2021 16:51:52 +0000 (+0000) Subject: Resolved Bug 1553 - Monitoring of certain infrastructure metrics fails in Openstack... X-Git-Tag: v9.1.2~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=88929d877f487961978231bab6a8d688d2d7a118;p=osm%2FMON.git Resolved Bug 1553 - Monitoring of certain infrastructure metrics fails in Openstack Stein and higher versions Change-Id: Ic657c949e11563e11228f0b2d988b9f6a91612f3 Signed-off-by: Atul Agarwal --- diff --git a/osm_mon/collector/vnf_collectors/openstack.py b/osm_mon/collector/vnf_collectors/openstack.py index a5c4980..a57eb46 100644 --- a/osm_mon/collector/vnf_collectors/openstack.py +++ b/osm_mon/collector/vnf_collectors/openstack.py @@ -55,6 +55,16 @@ METRIC_MAPPINGS = { "cpu_utilization": "cpu", } +# Metrics which have new names in Rocky and higher releases +METRIC_MAPPINGS_FOR_ROCKY_AND_NEWER_RELEASES = { + "disk_read_ops": "disk.device.read.requests", + "disk_write_ops": "disk.device.write.requests", + "disk_read_bytes": "disk.device.read.bytes", + "disk_write_bytes": "disk.device.write.bytes", + "packets_received": "network.incoming.packets", + "packets_sent": "network.outgoing.packets" + } + METRIC_MULTIPLIERS = { "cpu": 0.0000001 } @@ -127,7 +137,23 @@ class OpenstackCollector(BaseVimCollector): metric_type, metric_name, resource_id) - value = self.backend.collect_metric(metric_type, openstack_metric_name, resource_id) + value = self.backend.collect_metric( + metric_type, openstack_metric_name, resource_id + ) + + if value is None and metric_name in METRIC_MAPPINGS_FOR_ROCKY_AND_NEWER_RELEASES: + # Reattempting metric collection with new metric names. + # Some metric names have changed in newer Openstack releases + log.info( + "Reattempting metric collection for type: %s and name: %s and resource_id %s", + metric_type, + metric_name, + resource_id + ) + openstack_metric_name = METRIC_MAPPINGS_FOR_ROCKY_AND_NEWER_RELEASES[metric_name] + value = self.backend.collect_metric( + metric_type, openstack_metric_name, resource_id + ) if value is not None: log.info("value: %s", value) metric = VnfMetric(nsr_id, vnf_member_index, vdur['name'], metric_name, value, tags)