Resolved Bug 1553 - Monitoring of certain infrastructure metrics fails in Openstack... 39/10939/1
authorAtul Agarwal <Atul.Agarwal@altran.com>
Thu, 13 May 2021 11:39:30 +0000 (11:39 +0000)
committerpalsus <subhankar.pal@aricent.com>
Wed, 2 Jun 2021 11:17:40 +0000 (13:17 +0200)
Change-Id: I7f97e59f616d72e184b1d87a896f6b6afe513c14
Signed-off-by: Atul Agarwal <Atul.Agarwal@altran.com>
(cherry picked from commit 50d2909b27ad6449785235c7e0b075eac452c764)

osm_mon/collector/vnf_collectors/openstack.py

index 525bd00..5119f33 100644 (file)
@@ -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}
 
 METRIC_AGGREGATORS = {"cpu": "rate:mean"}
@@ -137,6 +147,20 @@ class OpenstackCollector(BaseVimCollector):
                         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(
@@ -224,7 +248,6 @@ class GnocchiBackend(OpenstackBackend):
                     if not total_measure:
                         total_measure = 0.0
                     total_measure += measures[-1][2]
-
             except (gnocchiclient.exceptions.NotFound, TypeError) as e:
                 # Gnocchi in some Openstack versions raise TypeError instead of NotFound
                 log.debug(