vector: [ansi_stripper] stripper doesn't strip color?
Hi,
ansi_stripper transform doesn’t remove ansi color from field?
For the following test:
[transforms.ansi_stripper_simple_yo]
inputs = []
type = "ansi_stripper"
field = "message"
[[tests]]
name = "ansi_stripper_simple_yo"
[tests.input]
insert_at = "ansi_stripper_simple_yo"
type = "raw"
value = "\t\r\\033[31mHelloWorld"
[[tests.outputs]]
extract_from = "ansi_stripper_simple_yo"
[[tests.outputs.conditions]]
"message.equals" = "HelloWorld"
It outputs:
check transform 'ansi_stripper_simple_yo' failed conditions:
condition[0]: predicates failed: [ message.equals: "HelloWorld" ]
payloads (events encoded as JSON):
input: {"message":"\t\r\\033[31mHelloWorld","timestamp":"2020-04-02T03:52:42.774856684Z"}
output: {"message":"\\033[31mHelloWorld","timestamp":"2020-04-02T03:52:42.774856684Z"}
Maybe it’s a wanted behavior and we should write ansi_color_stripper? WDYT?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (20 by maintainers)
Regarding the octal escape characters, it’s actually working as intended.
ansi_stripperis removing not printable and ANSI Escape sequences, soansi_stripperactually doesn’t deal with any\based escapes but with the actual characters like newline, tab, escape, etc. So it doesn’t remove\t,\r,\x1b, etc.The confusion arouse from different approaches that
ansi_stripper, Rust, andserde, have towards escape characters. Rust will in all but raw mode convert\t,\r,\x1b, etc. to the actual characters, soansi_stripperwill remove them, but won’t\033since Rust wont convert it. And the issue withserdeis covered with #2492 .In short,
ansi_stripperis stripping the color. There is no bug here, just a missing feature #2492 which only affectstomlconfiguration, and because of that the test in the config is failing . As such, I’ll close this issue.