Last active
June 20, 2024 14:00
-
-
Save TheCase/b0389757fb58fe45244317042a3405f0 to your computer and use it in GitHub Desktop.
Filbeats - remove ansi control characters for colored logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- script: | |
when: | |
regexp: | |
message: "[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]" | |
lang: javascript | |
id: remove_ansi_color | |
source: > | |
function process(event) { | |
var msg = event.Get("message") | |
var regex = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g | |
event.Put("message", msg.replace(regex, '')) | |
event.Tag("ansi_color_removed") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment