Logstash tcp output plugin

Hi,

I am using the Logstash TCP output plugin, and even though I removed the host field from my event, I still receive the %host string at the beginning of the event string. Is there any option to remove that? When I print the message in the console, it prints exactly as expected without the %host string. However, when I use the file output plugin, the same issue occurs.

Are you setting the codec option on the output?

If you run

input { generator { count => 1 lines => [ 'Hello, world!' ] } }
output { stdout { codec => line { } } }
output { stdout { codec => line { format => "%{message}" } } }

then the first output will produce

2024-08-14T21:50:59.332452045Z %{host} Hello, world!

and the second will produce

Hello, world!

That is because if the format option is not specified then it just calls .to_s on the event, and that adds the timestamp and host.

1 Like

Thank you so much for your response .it's working fine.