I'm not sure if this can be done with an existing filter plug-in without some recursions (if anyone knows by all means point it out), but it can be done somewhat cleanly with some custom Ruby code.
This should do what you want.
P.S. Since you didn't mention which version of Logstash you use (although I assume it's 5+) and event accessing methods have changed in 5.x, I have included both versions. Just delete the unneeded one.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.