Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/stanza] Add 'strip_ansi_escape_codes' operator #37443

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gjasny
Copy link
Contributor

@gjasny gjasny commented Jan 23, 2025

Description

We use the filelog receiver to ingest Artifactory logs. Some but not all of them contain ANSI color sequences. This makes regex creation pretty uncomfortable because both: log field separators and the ANSI color codes contain [ characters.

I was first thinking about using the add operator and removing the regex within the EXPR(). But I could not find any suitable regex function which works within that expression.

I could imagine that I'm not the only one who would like to get rid of colors. Therefore I believe that an easy to use operator enhances readability of the pipeline and is less error-prone than a (potentially) hand-crafted regex.

Testing

Added unit tests and tested locally against Artifactory log files.

@gjasny gjasny force-pushed the strip-ansi-escape-codes branch from b32fac5 to 411655a Compare January 23, 2025 14:15
Copy link
Contributor

@atoulme atoulme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a neat enhancement, thank you. I have reviewed the code and approve it, the codeowners have last word on accepting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants