I'm trying to replace the literal string "\x" with "\u00" just before parsing JSON to (somewhat naively) convert invalid hex escapes (coming from Nginx) into Unicode escapes. However no matter what I try I always get LogStash::Json::ParserError: Unexpected character ('\' (code 92)): was expecting double-quote to start field name
.
My filter:
filter {
mutate { gsub => [ "message", "\\x", "\\u00" ] }
json { source => "message" }
}
I've tried every combination of single, double and quadruple backslash in the regex pattern and replace values but no luck. Where am I going wrong?