OK. You could do it using json_encode (which you will need to install). First copy all the interesting fields to another field, which we can put in [@metadata]
mutate { remove_field => [ "@timestamp", "@version", "host", "message", "sequence" ] }
ruby {
code => '
event.to_hash.each { |k,v|
event.set("[@metadata][fields][#{k}]", v)
}
'
}
Then encode it into another field, which again can be in [@metadata]
json_encode { source => "[@metadata][fields]" target => "[@metadata][string]" }
and output it using a plain codec
output { stdout { codec => plain { format => "[ %{[@metadata][string]} ]
" } } }
Note that you use a literal newline in the format string to tell it to append a newline to the output.