JSON escaping in Logstash
Problem was in incorrect Logstash configuration. Logstash was running but not sending anything through filter. This is correct configuration:
input { tcp { port => 3333 type => "java" }}filter { if [type] == "java" { json { source => "message" } }}output { elasticsearch { hosts => "elasticsearch:9200" }}
I created a simple test and all you should need to add to your logstash configuration is codec => json
. The default value is "line"
and will escape the characters in the string.
input { tcp { port => 3333 codec => json }}output { stdout { codec => rubydebug } elasticsearch { hosts => "elasticsearch:9200" }}