From: Luis Vega Date: Mon, 17 Oct 2022 13:16:57 +0000 (+0000) Subject: Feature 10955: Osmclient changes related to VIM configuration with a Prometheus TSDB... X-Git-Tag: release-v13.0-start^0 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=cd8d60cb0d0c8f5e8247fbd4a1040f047b631f27;p=osm%2FMON.git Feature 10955: Osmclient changes related to VIM configuration with a Prometheus TSDB system Change-Id: I0222b0ff4b73ab923f03d5732c7b85e84d48bad6 Signed-off-by: Luis Vega --- diff --git a/osm_mon/collector/vnf_collectors/openstack.py b/osm_mon/collector/vnf_collectors/openstack.py index be2bdb7..514245b 100644 --- a/osm_mon/collector/vnf_collectors/openstack.py +++ b/osm_mon/collector/vnf_collectors/openstack.py @@ -56,6 +56,19 @@ METRIC_MAPPINGS = { "cpu_utilization": "cpu", } +METRIC_MAPPINGS_FOR_PROMETHEUS_TSBD = { + "cpu_utilization": "cpu", + "average_memory_utilization": "memory_usage", + "disk_read_ops": "disk_device_read_requests", + "disk_write_ops": "disk_device_write_requests", + "disk_read_bytes": "disk_device_read_bytes", + "disk_write_bytes": "disk_device_write_bytes", + "packets_in_dropped": "network_incoming_packets_drop", + "packets_out_dropped": "network_outgoing_packets_drop", + "packets_received": "network_incoming_packets", + "packets_sent": "network_outgoing_packets", +} + # Metrics which have new names in Rocky and higher releases METRIC_MAPPINGS_FOR_ROCKY_AND_NEWER_RELEASES = { "disk_read_ops": "disk.device.read.requests", @@ -131,7 +144,7 @@ class OpenstackCollector(BaseVimCollector): if "monitoring-parameter" in vdu: for param in vdu["monitoring-parameter"]: metric_name = param["performance-metric"] - log.debug(f"Using an {type(self.backend)} as backend") + log.info(f"Using an {type(self.backend)} as backend") if type(self.backend) is PrometheusTSBDBackend: openstack_metric_name = self.backend.map_metric(metric_name) else: @@ -243,14 +256,21 @@ class OpenstackBackend: class PrometheusTSBDBackend(OpenstackBackend): def __init__(self, vim_account: dict): - self.cred = vim_account["prometheus-config"]["prometheus_cred"] - self.map = vim_account["prometheus-config"]["prometheus_map"] - self.client = self._build_prometheus_client(vim_account) + self.map = self._build_map(vim_account) + self.cred = vim_account["prometheus-config"].get("prometheus-cred") + self.client = self._build_prometheus_client( + vim_account["prometheus-config"]["prometheus-url"] + ) - def _build_prometheus_client(self, vim_account: dict) -> prometheus_client: - url = vim_account["prometheus-config"]["prometheus_url"] + def _build_prometheus_client(self, url: str) -> prometheus_client: return prometheus_client(url, disable_ssl=True) + def _build_map(self, vim_account: dict) -> dict: + custom_map = METRIC_MAPPINGS_FOR_PROMETHEUS_TSBD + if "prometheus-map" in vim_account["prometheus-config"]: + custom_map.update(vim_account["prometheus-config"]["prometheus-map"]) + return custom_map + def collect_metric( self, metric_type: MetricType, metric_name: str, resource_id: str ):