인프라,데이터/Fluentd, Fluent Bit
Remove last n characters using Regex & Fluent Bit
AimB
2022. 3. 2. 18:37
I took a quite a munutes to find "remove / delete last n characters / words by regex" but there was no explicit answer.
However, I found a solution.
[FILTER]
Name parser
Match test.*
Key_Name path
Parser removelastn
Reserve_Data On
Preserve_key On
[PARSER]
Name removelastn
Format regex
Regex (?<log>.*?).{6}$

(?<log>.*?) means "log" might not exist, anyway it catch all characters or nothing("")
.{6}$ means last 6 characters.
if you using this way, you don't need a replacer. you can erase last n words just by simple regex itself.