X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcollector%2Fvnf_collectors%2Fopenstack.py;h=514245be1ad3a3dee98f295572adee3876e0508c;hb=refs%2Fchanges%2F94%2F12594%2F6;hp=be2bdb7078e70608a85bf45a4d6c891ecaedac5f;hpb=e11d5666a1adfcb2880d99ed16554cdc000507b7;p=osm%2FMON.git 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 ):