X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fosm_ngsa%2Fdags%2Fmultivim_vim_status.py;h=d9f54bb12cfca254f99eb720a16b55d82f020b24;hb=54c033b73391a95c16f8ec737a9970072763acb2;hp=f63ab4f41077da16d86b24cc1978eecf45bc4433;hpb=f0afc25c9e0fbb5546868eb232b26ff911fa636b;p=osm%2FNG-SA.git diff --git a/src/osm_ngsa/dags/multivim_vim_status.py b/src/osm_ngsa/dags/multivim_vim_status.py index f63ab4f..d9f54bb 100644 --- a/src/osm_ngsa/dags/multivim_vim_status.py +++ b/src/osm_ngsa/dags/multivim_vim_status.py @@ -30,7 +30,7 @@ from prometheus_client import CollectorRegistry, Gauge, push_to_gateway SUPPORTED_VIM_TYPES = ["openstack", "vio", "gcp", "azure"] PROMETHEUS_PUSHGW = "pushgateway-prometheus-pushgateway:9091" PROMETHEUS_JOB_PREFIX = "airflow_osm_vim_status_" -PROMETHEUS_METRIC = "vim_status" +PROMETHEUS_METRIC = "osm_vim_status" PROMETHEUS_METRIC_DESCRIPTION = "VIM status" SCHEDULE_INTERVAL = 1 @@ -85,7 +85,7 @@ def create_dag(dag_id, dag_number, dag_description, vim_id): vim_type = vim_account["config"]["vim_type"].lower() if vim_type == "vio" and "vrops_site" not in vim_account["config"]: vim_type = "openstack" - if vim_type == "openstack": + if vim_type == "openstack" or vim_type == "vio": return OpenStackCollector(vim_account) if vim_type == "gcp": return GcpCollector(vim_account) @@ -111,7 +111,7 @@ def create_dag(dag_id, dag_number, dag_description, vim_id): PROMETHEUS_METRIC, PROMETHEUS_METRIC_DESCRIPTION, labelnames=[ - "vim_id", + "vim_account_id", ], registry=registry, ) @@ -122,7 +122,8 @@ def create_dag(dag_id, dag_number, dag_description, vim_id): if collector: status = collector.is_vim_ok() logger.info(f"VIM status: {status}") - metric.labels(vim_id).set(1) + if status: + metric.labels(vim_id).set(1) else: logger.info("Error creating VIM collector") # Push to Prometheus