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()
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)
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
"vim_id",
"vdu_name",
"vnf_member_index",
+ "ns_name",
],
registry=registry,
)
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
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}"
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}"
)
vim_id,
vdu_name,
vnf_membex_index,
+ ns_name,
).set(1)
push_to_gateway(