From 872cf4044e1af3a0022382588adbb3e29ad1879a Mon Sep 17 00:00:00 2001 From: Rahul Zamre Date: Tue, 14 May 2024 11:49:16 +0100 Subject: [PATCH] Bug 2337 - Grafana dashboards do not work when NG-SA is enabled Change-Id: I3e989e4ed675a0638973e9c95a79416187db5627 Signed-off-by: Rahul Zamre Signed-off-by: garciadeblas --- src/osm_ngsa/dags/multivim_vim_status.py | 14 +++++++++++--- src/osm_ngsa/dags/ns_topology.py | 8 ++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/osm_ngsa/dags/multivim_vim_status.py b/src/osm_ngsa/dags/multivim_vim_status.py index d9f54bb..2f71bc9 100644 --- a/src/osm_ngsa/dags/multivim_vim_status.py +++ b/src/osm_ngsa/dags/multivim_vim_status.py @@ -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 diff --git a/src/osm_ngsa/dags/ns_topology.py b/src/osm_ngsa/dags/ns_topology.py index 7d2af07..a3983c4 100644 --- a/src/osm_ngsa/dags/ns_topology.py +++ b/src/osm_ngsa/dags/ns_topology.py @@ -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( -- 2.25.1