Skip to content

Commit 37493ec

Browse files
committed
fix: Restore colored logs, strip ANSI escape codes in Vector agent
1 parent 046a376 commit 37493ec

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

crates/stackable-operator/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ All notable changes to this project will be documented in this file.
99
- Support the annotation `secrets.stackable.tech/backend.autotls.cert.domain-components-in-subject-dn`
1010
in the `SecretOperatorVolumeSourceBuilder` ([#1209]).
1111

12+
### Fixed
13+
14+
- Strip ANSI escape codes (e.g. colors) from captured shell stdout/stderr in the generated Vector
15+
agent config, so they no longer show up as garbled text in log aggregators such as OpenSearch ([#XXX]).
16+
1217
[#1209]: https://github.com/stackabletech/operator-rs/pull/1209
18+
[#XXX]: https://github.com/stackabletech/operator-rs/pull/XXX
1319

1420
## [0.113.0] - 2026-06-22
1521

crates/stackable-operator/src/product_logging/framework.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,11 @@ transforms:
924924
source: |
925925
.logger = "ROOT"
926926
.level = "INFO"
927+
# containers capture raw stdout, which can contain ANSI escape codes (colors) emitted by the
928+
# tools they run (e.g. containerdebug, cert-tools). These codes are unreadable in log
929+
# aggregators such as OpenSearch, so we strip them here. On failure (e.g. non-string message)
930+
# we keep the original message untouched.
931+
.message = strip_ansi_escape_codes(.message) ?? .message
927932
928933
processed_files_stderr:
929934
inputs:
@@ -932,6 +937,8 @@ transforms:
932937
source: |
933938
.logger = "ROOT"
934939
.level = "ERROR"
940+
# See above for why we strip ANSI escape codes.
941+
.message = strip_ansi_escape_codes(.message) ?? .message
935942
936943
processed_files_log4j:
937944
inputs:

crates/stackable-telemetry/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Fixed
8+
9+
- Revert [#1183], so we again default to ANSI escape sequences, which can be turned off using
10+
`NO_COLOR=1` ([#XXXX]).
11+
12+
[#XXXX]: https://github.com/stackabletech/operator-rs/pull/XXXX
13+
714
## [0.6.4] - 2026-06-03
815

916
Note: There are only dependency bumps in this release

crates/stackable-telemetry/src/tracing/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//!
77
//! To get started, see [`Tracing`].
88
9-
use std::{io::IsTerminal, ops::Not, path::PathBuf};
9+
use std::{ops::Not, path::PathBuf};
1010

1111
use opentelemetry::trace::TracerProvider;
1212
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
@@ -436,21 +436,15 @@ impl Tracing {
436436

437437
// NOTE (@NickLarsenNZ): There is no elegant way to build the layer depending on formats because the types
438438
// returned from each subscriber "modifier" function is different (sometimes with different generics).
439-
// tracing-subscriber does not auto-detect whether stdout is a terminal
440-
// (https://github.com/tokio-rs/tracing/issues/1160), so we check explicitly.
441-
let use_ansi = std::io::stdout().is_terminal();
442-
443439
match log_format {
444440
Format::Plain => {
445-
let console_output_layer = tracing_subscriber::fmt::layer()
446-
.with_ansi(use_ansi)
447-
.with_filter(env_filter_layer);
441+
let console_output_layer =
442+
tracing_subscriber::fmt::layer().with_filter(env_filter_layer);
448443
layers.push(console_output_layer.boxed());
449444
}
450445
Format::Json => {
451446
let console_output_layer = tracing_subscriber::fmt::layer()
452447
.json()
453-
.with_ansi(use_ansi)
454448
.with_filter(env_filter_layer);
455449
layers.push(console_output_layer.boxed());
456450
}

0 commit comments

Comments
 (0)