From 4bc6bc29b3f7ca930b1256984302b294d54ace33 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 13 Nov 2024 10:35:36 +0200 Subject: [PATCH] small fixes --- .../fluentd_telemetry_plugin/src/streamer.py | 18 ++++++++++-------- .../src/telemetry_parser.py | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/plugins/fluentd_telemetry_plugin/src/streamer.py b/plugins/fluentd_telemetry_plugin/src/streamer.py index 59249605..bfdd58d8 100644 --- a/plugins/fluentd_telemetry_plugin/src/streamer.py +++ b/plugins/fluentd_telemetry_plugin/src/streamer.py @@ -51,7 +51,9 @@ def __init__(self, conf_parser): self.streaming_metrics_mgr = MonitorStreamingMgr() self._fluent_sender = None self.attributes_mngr = TelemetryAttributesManager() - self.telem_parser = TelemetryParser(self.config_parser, self.streaming_metrics_mgr, self.last_streamed_data_sample_per_endpoint, self.attributes_mngr) + self.telem_parser = TelemetryParser(self.config_parser, self.streaming_metrics_mgr, + self.last_streamed_data_sample_per_endpoint, + self.attributes_mngr) self.init_streaming_attributes() @property @@ -95,7 +97,7 @@ def ufm_telemetry_endpoints(self): endpoints = [] for i, value in enumerate(hosts): _is_xdr_mode = Utils.convert_str_to_type(xdr_mode[i], 'boolean') - _url = TelemetryParser._append_filters_to_telemetry_url( + _url = TelemetryParser.append_filters_to_telemetry_url( urls[i], _is_xdr_mode, xdr_ports_types[i].split(self.config_parser.UFM_TELEMETRY_ENDPOINT_SECTION_XDR_PORTS_TYPE_SPLITTER) @@ -179,12 +181,12 @@ def init_streaming_attributes(self): # pylint: disable=too-many-locals telemetry_data = self.telem_parser.get_metrics(_host, _port, _url, _msg_tag) if telemetry_data: - # CSV format - rows = telemetry_data.split("\n") - if len(rows): - headers = rows[0].split(",") - for attribute in headers: - self.attributes_mngr.add_streaming_attribute(attribute) + # CSV format + rows = telemetry_data.split("\n") + if len(rows): + headers = rows[0].split(",") + for attribute in headers: + self.attributes_mngr.add_streaming_attribute(attribute) processed_endpoints[endpoint_id] = True # update the streaming attributes files diff --git a/plugins/fluentd_telemetry_plugin/src/telemetry_parser.py b/plugins/fluentd_telemetry_plugin/src/telemetry_parser.py index b619c06b..edd5a322 100644 --- a/plugins/fluentd_telemetry_plugin/src/telemetry_parser.py +++ b/plugins/fluentd_telemetry_plugin/src/telemetry_parser.py @@ -14,12 +14,12 @@ @date: Nov 13, 2024 """ import logging -import requests from typing import List +import requests +from telemetry_constants import UFMTelemetryConstants from ufm_sdk_tools.src.xdr_utils import PortType,prepare_port_type_http_telemetry_filter from utils.logger import Logger, LOG_LEVELS -from telemetry_constants import UFMTelemetryConstants from utils.utils import Utils class TelemetryParser: @@ -49,7 +49,7 @@ def __init__(self, conf_parser, monitor_streaming_mgr, _last_streamed_data_sampl self.attributes_mngr = attr_mngr @staticmethod - def _append_filters_to_telemetry_url(url: str, xdr_mode: bool, port_types: List[str]): + def append_filters_to_telemetry_url(url: str, xdr_mode: bool, port_types: List[str]): """ This function constructs and appends filter parameters to the given URL if certain conditions are met.