From 37493ec0674537d7b831631302ecf462a3aa5d1c Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 30 Jun 2026 12:39:08 +0200 Subject: [PATCH 1/4] fix: Restore colored logs, strip ANSI escape codes in Vector agent --- crates/stackable-operator/CHANGELOG.md | 6 ++++++ .../src/product_logging/framework.rs | 7 +++++++ crates/stackable-telemetry/CHANGELOG.md | 7 +++++++ crates/stackable-telemetry/src/tracing/mod.rs | 12 +++--------- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index f8d19421a..9db50d393 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -9,7 +9,13 @@ All notable changes to this project will be documented in this file. - Support the annotation `secrets.stackable.tech/backend.autotls.cert.domain-components-in-subject-dn` in the `SecretOperatorVolumeSourceBuilder` ([#1209]). +### Fixed + +- Strip ANSI escape codes (e.g. colors) from captured shell stdout/stderr in the generated Vector + agent config, so they no longer show up as garbled text in log aggregators such as OpenSearch ([#XXX]). + [#1209]: https://github.com/stackabletech/operator-rs/pull/1209 +[#XXX]: https://github.com/stackabletech/operator-rs/pull/XXX ## [0.113.0] - 2026-06-22 diff --git a/crates/stackable-operator/src/product_logging/framework.rs b/crates/stackable-operator/src/product_logging/framework.rs index 35c7bab02..2c2757869 100644 --- a/crates/stackable-operator/src/product_logging/framework.rs +++ b/crates/stackable-operator/src/product_logging/framework.rs @@ -924,6 +924,11 @@ transforms: source: | .logger = "ROOT" .level = "INFO" + # containers capture raw stdout, which can contain ANSI escape codes (colors) emitted by the + # tools they run (e.g. containerdebug, cert-tools). These codes are unreadable in log + # aggregators such as OpenSearch, so we strip them here. On failure (e.g. non-string message) + # we keep the original message untouched. + .message = strip_ansi_escape_codes(.message) ?? .message processed_files_stderr: inputs: @@ -932,6 +937,8 @@ transforms: source: | .logger = "ROOT" .level = "ERROR" + # See above for why we strip ANSI escape codes. + .message = strip_ansi_escape_codes(.message) ?? .message processed_files_log4j: inputs: diff --git a/crates/stackable-telemetry/CHANGELOG.md b/crates/stackable-telemetry/CHANGELOG.md index af9038a73..24e942577 100644 --- a/crates/stackable-telemetry/CHANGELOG.md +++ b/crates/stackable-telemetry/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed + +- Revert [#1183], so we again default to ANSI escape sequences, which can be turned off using + `NO_COLOR=1` ([#XXXX]). + +[#XXXX]: https://github.com/stackabletech/operator-rs/pull/XXXX + ## [0.6.4] - 2026-06-03 Note: There are only dependency bumps in this release diff --git a/crates/stackable-telemetry/src/tracing/mod.rs b/crates/stackable-telemetry/src/tracing/mod.rs index 64b75e4be..dbe641db5 100644 --- a/crates/stackable-telemetry/src/tracing/mod.rs +++ b/crates/stackable-telemetry/src/tracing/mod.rs @@ -6,7 +6,7 @@ //! //! To get started, see [`Tracing`]. -use std::{io::IsTerminal, ops::Not, path::PathBuf}; +use std::{ops::Not, path::PathBuf}; use opentelemetry::trace::TracerProvider; use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge; @@ -436,21 +436,15 @@ impl Tracing { // NOTE (@NickLarsenNZ): There is no elegant way to build the layer depending on formats because the types // returned from each subscriber "modifier" function is different (sometimes with different generics). - // tracing-subscriber does not auto-detect whether stdout is a terminal - // (https://github.com/tokio-rs/tracing/issues/1160), so we check explicitly. - let use_ansi = std::io::stdout().is_terminal(); - match log_format { Format::Plain => { - let console_output_layer = tracing_subscriber::fmt::layer() - .with_ansi(use_ansi) - .with_filter(env_filter_layer); + let console_output_layer = + tracing_subscriber::fmt::layer().with_filter(env_filter_layer); layers.push(console_output_layer.boxed()); } Format::Json => { let console_output_layer = tracing_subscriber::fmt::layer() .json() - .with_ansi(use_ansi) .with_filter(env_filter_layer); layers.push(console_output_layer.boxed()); } From 0f5dda1a14af52ab0441ef5c1fd0b5bd7b8db9ed Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 30 Jun 2026 13:59:48 +0200 Subject: [PATCH 2/4] casing --- crates/stackable-operator/src/product_logging/framework.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/stackable-operator/src/product_logging/framework.rs b/crates/stackable-operator/src/product_logging/framework.rs index 2c2757869..819bafb0d 100644 --- a/crates/stackable-operator/src/product_logging/framework.rs +++ b/crates/stackable-operator/src/product_logging/framework.rs @@ -924,7 +924,7 @@ transforms: source: | .logger = "ROOT" .level = "INFO" - # containers capture raw stdout, which can contain ANSI escape codes (colors) emitted by the + # Containers capture raw stdout, which can contain ANSI escape codes (colors) emitted by the # tools they run (e.g. containerdebug, cert-tools). These codes are unreadable in log # aggregators such as OpenSearch, so we strip them here. On failure (e.g. non-string message) # we keep the original message untouched. From 9c70c4c56bafcea4a9f741d4ecf55594e25cda53 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 30 Jun 2026 14:00:42 +0200 Subject: [PATCH 3/4] changelog --- crates/stackable-operator/CHANGELOG.md | 4 ++-- crates/stackable-telemetry/CHANGELOG.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 9db50d393..1bb0cd6ee 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -12,10 +12,10 @@ All notable changes to this project will be documented in this file. ### Fixed - Strip ANSI escape codes (e.g. colors) from captured shell stdout/stderr in the generated Vector - agent config, so they no longer show up as garbled text in log aggregators such as OpenSearch ([#XXX]). + agent config, so they no longer show up as garbled text in log aggregators such as OpenSearch ([#1237]). [#1209]: https://github.com/stackabletech/operator-rs/pull/1209 -[#XXX]: https://github.com/stackabletech/operator-rs/pull/XXX +[#1237]: https://github.com/stackabletech/operator-rs/pull/1237 ## [0.113.0] - 2026-06-22 diff --git a/crates/stackable-telemetry/CHANGELOG.md b/crates/stackable-telemetry/CHANGELOG.md index 24e942577..0be6cfe8b 100644 --- a/crates/stackable-telemetry/CHANGELOG.md +++ b/crates/stackable-telemetry/CHANGELOG.md @@ -7,9 +7,9 @@ All notable changes to this project will be documented in this file. ### Fixed - Revert [#1183], so we again default to ANSI escape sequences, which can be turned off using - `NO_COLOR=1` ([#XXXX]). + `NO_COLOR=1` ([#1237]). -[#XXXX]: https://github.com/stackabletech/operator-rs/pull/XXXX +[#1237]: https://github.com/stackabletech/operator-rs/pull/1237 ## [0.6.4] - 2026-06-03 From 6e3590da034da722d17100e3b731852534f75b57 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 30 Jun 2026 14:03:00 +0200 Subject: [PATCH 4/4] changelog --- crates/stackable-telemetry/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/stackable-telemetry/CHANGELOG.md b/crates/stackable-telemetry/CHANGELOG.md index 0be6cfe8b..d1e47f39d 100644 --- a/crates/stackable-telemetry/CHANGELOG.md +++ b/crates/stackable-telemetry/CHANGELOG.md @@ -7,7 +7,9 @@ All notable changes to this project will be documented in this file. ### Fixed - Revert [#1183], so we again default to ANSI escape sequences, which can be turned off using - `NO_COLOR=1` ([#1237]). + `NO_COLOR=1`. + This way we keep colored logs for human consumption. + Instead we adopted the Vector config, so that the Vector sidecar strips ANSI codes ([#1237]). [#1237]: https://github.com/stackabletech/operator-rs/pull/1237