diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index f8d19421a..1bb0cd6ee 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 ([#1237]). + [#1209]: https://github.com/stackabletech/operator-rs/pull/1209 +[#1237]: https://github.com/stackabletech/operator-rs/pull/1237 ## [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..819bafb0d 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..d1e47f39d 100644 --- a/crates/stackable-telemetry/CHANGELOG.md +++ b/crates/stackable-telemetry/CHANGELOG.md @@ -4,6 +4,15 @@ 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`. + 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 + ## [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()); }