Bug 2337 - Grafana dashboards do not work when NG-SA is enabled 28/14628/1
authorRahul Zamre <rzamre@indracompany.com>
Tue, 14 May 2024 10:49:16 +0000 (11:49 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 7 Oct 2024 19:46:17 +0000 (21:46 +0200)
Change-Id: I3e989e4ed675a0638973e9c95a79416187db5627
Signed-off-by: Rahul Zamre <rzamre@indracompany.com>
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
src/osm_ngsa/dags/multivim_vim_status.py
src/osm_ngsa/dags/ns_topology.py

index d9f54bb..2f71bc9 100644 (file)
@@ -103,7 +103,11 @@ def create_dag(dag_id, dag_number, dag_description, vim_id):
             cfg = Config()
             common_db = CommonDbClient(cfg)
             vim_account = common_db.get_vim_account(vim_account_id=vim_id)
-            logger.info(vim_account)
+            vim_name = vim_account["name"]
+            logger.info(f"vim_account: {vim_account}")
+            logger.info(f"vim_name: {vim_name}")
+            projects_read = vim_account["_admin"]["projects_read"]
+            logger.info(f"projects_read: {projects_read}")
 
             # Define Prometheus Metric for NS topology
             registry = CollectorRegistry()
@@ -112,10 +116,13 @@ def create_dag(dag_id, dag_number, dag_description, vim_id):
                 PROMETHEUS_METRIC_DESCRIPTION,
                 labelnames=[
                     "vim_account_id",
+                    "project_id",
+                    "vim_name",
                 ],
                 registry=registry,
             )
-            metric.labels(vim_id).set(0)
+            for project_id in projects_read:
+                metric.labels(vim_id, project_id, vim_name).set(0)
 
             # Get status of VIM
             collector = get_vim_collector(vim_account)
@@ -123,7 +130,8 @@ def create_dag(dag_id, dag_number, dag_description, vim_id):
                 status = collector.is_vim_ok()
                 logger.info(f"VIM status: {status}")
                 if status:
-                    metric.labels(vim_id).set(1)
+                    for project_id in projects_read:
+                        metric.labels(vim_id, project_id, vim_name).set(1)
             else:
                 logger.info("Error creating VIM collector")
             # Push to Prometheus
index 7d2af07..a3983c4 100644 (file)
@@ -70,6 +70,7 @@ def ns_topology():
                 "vim_id",
                 "vdu_name",
                 "vnf_member_index",
+                "ns_name",
             ],
             registry=registry,
         )
@@ -91,6 +92,8 @@ def ns_topology():
             vnf_id = vnfr["_id"]
             # Label ns_id
             ns_id = vnfr["nsr-id-ref"]
+            nsr = common_db.get_nsr(ns_id)
+            ns_name = nsr["name"]
             # Label vnfd_id
             vnfd_id = vnfr["vnfd-ref"]
             # Label project_id
@@ -102,7 +105,7 @@ def ns_topology():
             ns_state = vnfr["_admin"]["nsState"]
             vnf_membex_index = vnfr["member-vnf-index-ref"]
             logger.info(
-                f"Read VNFR: id: {vnf_id}, ns_id: {ns_id}, "
+                f"Read VNFR: id: {vnf_id}, ns_id: {ns_id}, ns_name: {ns_name} "
                 f"state: {ns_state}, vnfd_id: {vnfd_id}, "
                 f"vnf_membex_index: {vnf_membex_index}, "
                 f"project_id: {project_id}"
@@ -137,7 +140,7 @@ def ns_topology():
                     f"vim_id: {vim_id}, vm_id: {vm_id}"
                 )
                 logger.info(
-                    f"METRIC SAMPLE: ns_id: {ns_id}, "
+                    f"METRIC SAMPLE: ns_id: {ns_id}, ns_name: {ns_name}"
                     f"project_id: {project_id}, vnf_id: {vnf_id}, "
                     f"vdu_id: {vdu_id}, vm_id: {vm_id}, vim_id: {vim_id}"
                 )
@@ -150,6 +153,7 @@ def ns_topology():
                     vim_id,
                     vdu_name,
                     vnf_membex_index,
+                    ns_name,
                 ).set(1)
 
         push_to_gateway(