From f283ff0b23e161533120c7820db3b944273e5d63 Mon Sep 17 00:00:00 2001 From: Mike Schiessl <77062930+MikeSchiessl@users.noreply.github.com> Date: Mon, 23 Sep 2024 10:18:36 +0200 Subject: [PATCH] v1.8.3 (#75) v1.8.3 --- Dockerfile | 2 +- bin/uls.py | 23 +++++++++++-------- bin/uls_config/global_config.py | 2 +- docs/CHANGELOG.md | 17 +++++++++++++- .../kubernetes/helm/akamai-uls/Chart.yaml | 2 +- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7c732be..fe9ba62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ ARG EXT_DIR="$ULS_DIR/ext" ARG ETP_CLI_VERSION="0.4.8" ARG EAA_CLI_VERSION="0.6.10" ARG MFA_CLI_VERSION="0.1.1" -ARG GC_CLI_VERSION="v0.0.5" +ARG GC_CLI_VERSION="v0.0.6" ARG LINODE_CLI_VERSION="dev" ARG ACC_CLI_VERSION="v0.0.1-alpha" diff --git a/bin/uls.py b/bin/uls.py index 10c79ce..c893d1b 100755 --- a/bin/uls.py +++ b/bin/uls.py @@ -145,14 +145,15 @@ def main(): cliformat=uls_args.cliformat, transformationpattern=uls_args.transformationpattern) + filter_escaped = uls_args.filter.replace('"', '\\"') if uls_args.filter else None # Prepare the Filter if uls_args.filter: try: aka_log.log.info(f"FILTER pattern has been specified: " - f"{uls_args.filter} - will only output matches") + f"{filter_escaped} - will only output matches") filter_pattern = re.compile(uls_args.filter.encode()) except Exception as my_error: - aka_log.log.critical(f"Error in filter patter {uls_args.filter}" + aka_log.log.critical(f"Error in filter pattern {filter_escaped}" f" (exiting). Error: {my_error}") sys.exit(1) else: @@ -192,11 +193,12 @@ def main(): try: input_data = event_q.get(block=True, timeout=0.05) if uls_args.debugloglines: - aka_log.log.debug(f" {input_data}") + escaped_data = input_data.decode('utf-8').replace('"', '\\"') + aka_log.log.debug(f" {escaped_data}") for log_line in input_data.splitlines(): + log_line_escaped = log_line.decode('utf-8').replace('"', '\\"') # Write checkpoint to the checkpoint file (if autoresume is enabled) (not after transformation or filter) - if uls_args.autoresume and int(my_monitor.get_message_count()) >= autoresume_lastwrite + uls_args.autoresumewriteafter: aka_log.log.info(f"WRITING AUTORESUME CHECKPOINT - curr_message_count={int(my_monitor.get_message_count())} - last_write = {autoresume_lastwrite}") UlsTools.write_autoresume_ckpt(uls_args.input, @@ -208,16 +210,17 @@ def main(): # Filter Enhancement if uls_args.filter and not filter_pattern.match(log_line): - aka_log.log.info(f"SKIPPED LINE due to FILTER rule {uls_args.filter}") + aka_log.log.info(f"SKIPPED LINE due to FILTER rule {filter_escaped}") aka_log.log.debug(f"SKIPPED the following LOG_LINE " - f"due to FILTER match: {log_line}") + f"due to FILTER match: {log_line_escaped}") continue # Transformation Enhancement if uls_args.transformation: log_line = my_transformer.transform(log_line) + log_line_escaped = log_line.decode('utf-8').replace('"', '\\"') aka_log.log.debug(f"Transformed Logline via " - f"({uls_args.transformation}): {log_line}") + f"({uls_args.transformation}): {log_line_escaped}") # Attach Linebreak #out_data = log_line + uls_config.output_line_breaker.encode() @@ -235,21 +238,21 @@ def main(): resend_status = my_output.send_data(log_line) my_monitor.increase_message_count(len(log_line)) if uls_args.debugloglines: - aka_log.log.debug(f" {log_line}") + aka_log.log.debug(f" {log_line_escaped}") resend_counter = resend_counter + 1 if resend_counter == uls_config.main_resend_attempts and\ uls_config.main_resend_exit_on_fail: aka_log.log.critical(f"MSG[{my_monitor.get_message_count()}] " f"ULS was not able to deliver the log message " - f"{log_line.decode()} after {resend_counter} attempts - Exiting!") + f"{log_line_escaped} after {resend_counter} attempts - Exiting!") sys.exit(1) elif resend_counter == uls_config.main_resend_attempts and \ not uls_config.main_resend_exit_on_fail: aka_log.log.warning( f"MSG[{my_monitor.get_message_count()}] " f"ULS was not able to deliver the log message " - f"{log_line.decode()} after {resend_counter} attempts - (continuing anyway as my config says)") + f"{log_line_escaped} after {resend_counter} attempts - (continuing anyway as my config says)") except queue.Empty: # No data available, we get a chance to capture the StopEvent pass diff --git a/bin/uls_config/global_config.py b/bin/uls_config/global_config.py index 74dd87c..a0c8018 100644 --- a/bin/uls_config/global_config.py +++ b/bin/uls_config/global_config.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 import sys # Common global variables / constants -__version__ = "1.8.2" +__version__ = "1.8.3" __tool_name_long__ = "Akamai Unified Log Streamer" __tool_name_short__ = "ULS" diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f436a32..da55416 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,9 +1,24 @@ # Version History +## v1.8.3 +| | | +|--------|---------------------| +| Date | 2024-09-23 | +| Kind | MINOR release | +| Author | mschiess@akamai.com | + +- **Minor improvements** + - [docker] bumped CLI-GC version to 0.0.6 + +- **Bugfixes** + - Improved JSON Log Escaping (massive thx to @sethumadhav07 for the privded PR) + +--- + ## v1.8.2 | | | |--------|---------------------| -| Date | 2024-XX-XX | +| Date | 2024-09-11 | | Kind | MINOR release | | Author | mschiess@akamai.com | diff --git a/docs/examples/kubernetes/helm/akamai-uls/Chart.yaml b/docs/examples/kubernetes/helm/akamai-uls/Chart.yaml index 02fcbad..4438581 100644 --- a/docs/examples/kubernetes/helm/akamai-uls/Chart.yaml +++ b/docs/examples/kubernetes/helm/akamai-uls/Chart.yaml @@ -4,4 +4,4 @@ description: Akamai Universal Log Streamer Helm installation type: application version: 2.0.0 -appVersion: "1.8.2" +appVersion: "1.8.3"