Fixes autoscaling with VNF Indicators 49/8349/2
authorGianpietro Lavado <glavado@whitestack.com>
Sun, 8 Dec 2019 20:21:10 +0000 (20:21 +0000)
committerGianpietro Lavado <glavado@whitestack.com>
Sun, 8 Dec 2019 20:25:10 +0000 (20:25 +0000)
Adds vdu_name to VNF Indicators collection.
This fixes autoscaling as Prometheus is queried using alarm
tags, which includes vdu_name.

Change-Id: I68e6368e4839b96737142be426d82d1b1e07e186
Signed-off-by: Gianpietro Lavado <glavado@whitestack.com>
osm_mon/collector/vnf_collectors/juju.py

index 8f3fa34..82ee98f 100644 (file)
@@ -90,11 +90,19 @@ class VCACollector(BaseCollector):
                 return metrics
             measures = self.loop.run_until_complete(self.n2vc.GetMetrics(vca_deployment_info['model'],
                                                                          vca_deployment_info['application']))
+            # Search for Mgmt VDU name, needed to query Prometheus based on alarm tags
+            # TODO: check a better way to look for Mgmt VDU
+            for vdur in vnfr['vdur']:
+                for interface in vdur['interfaces']:
+                    if 'mgmt-vnf' in interface:
+                        vdu_name = vdur['name']
+                        break
             log.debug('Measures: %s', measures)
             for measure_list in measures.values():
                 for measure in measure_list:
                     log.debug("Measure: %s", measure)
-                    metric = VnfMetric(nsr_id, vnf_member_index, '', measure['key'], float(measure['value']), tags)
+                    metric = VnfMetric(nsr_id, vnf_member_index, vdu_name,
+                                       measure['key'], float(measure['value']), tags)
                     metrics.append(metric)
         return metrics