Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 13, 2024
1 parent f31771b commit c3d1beb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 0 additions & 3 deletions plugins/fluentd_telemetry_plugin/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@
from web_service import UFMTelemetryFluentdStreamingAPI
from streamer import UFMTelemetryStreaming
from streaming_config_parser import UFMTelemetryStreamingConfigParser
from telemetry_constants import UFMTelemetryConstants
from streaming_scheduler import StreamingScheduler

# pylint: disable=no-name-in-module,import-error
from utils.flask_server import run_api
from utils.args_parser import ArgsParser
from utils.logger import Logger
from utils.utils import Utils

Expand All @@ -45,7 +43,6 @@ def _init_logs(config_parser):
if __name__ == '__main__':

# init app config parser & load config files
# args = ArgsParser.parse_args("UFM Telemetry Streaming to fluentd", UFMTelemetryConstants.args_list)
_config_parser = UFMTelemetryStreamingConfigParser()

_init_logs(_config_parser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
from utils.utils import Utils

class TelemetryAttributesManager:
""""
UFM TelemetryAttributesManager class - to manager streaming attributes
When we parse the telemetry data, we should update saved/cached attributes (headers) and file (/config/tfs_streaming_attributes.json)
"""

def __init__(self):
self.streaming_attributes_file = "/config/tfs_streaming_attributes.json" # this path on the docker
Expand Down
8 changes: 5 additions & 3 deletions plugins/fluentd_telemetry_plugin/src/telemetry_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
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 telemetry_attributes_manager import TelemetryAttributesManager
from utils.utils import Utils

class TelemetryParser:
"""
UFM TelemetryParser class - to fetch and parse the telemetry data
"""

PORT_CONSTANTS_KEYS = {
'timestamp': 'timestamp', 'source_id': 'source_id', 'tag': 'tag',
Expand Down Expand Up @@ -156,7 +158,7 @@ def _parse_telemetry_csv_metrics_to_json_with_delta(self, available_headers, row
is_constant_value = TelemetryParser.PORT_CONSTANTS_KEYS.get(key)
if value:
# the value of this counter not empty
value = self._convert_str_to_num(value)
value = TelemetryParser._convert_str_to_num(value)
if is_constant_value is None and value != current_port_values.get(key):
# the value was changed -> stream it
dic[key] = value
Expand Down Expand Up @@ -230,7 +232,7 @@ def _parse_telemetry_csv_metrics_to_json_without_delta(self, available_headers,
value = values[i]
key = available_headers[i]
if value:
port_record[key] = self._convert_str_to_num(value)
port_record[key] = TelemetryParser._convert_str_to_num(value)
self.last_streamed_data_sample_per_endpoint[endpoint_key][port_key] = port_record
if is_meta_fields_available:
port_record = self._append_meta_fields_to_dict(port_record)
Expand Down

0 comments on commit c3d1beb

Please sign in to comment.