Avoid Timestamp and host from the logstash file output

Hi I am using very simple configuration.
Receive strings from TCP input and write to a file
Sent string
This is new string 8
Written in to file
2022-09-21T12:36:28.278922Z %{host} This is new string 8

I want to avoid the timestamp and%{host} in the file

Can someone suggest. Here is my conf file?

input {
tcp {
host => "1.1.1.1"
port => 33333
codec => line
}
}
output {
file {
path => "/var/log/rajeshltrace.log"
create_if_deleted => true
flush_interval => 1
codec => line
}

If you do not supply the format option to the line codec then it will call event.to_s, which adds the timestamp and hostname. Change it to

codec => line { format => "%{message}" }

Thank you @Badger :pray:

One more small query, I could see Hostname getting populated as Ip address when I use UDP but when I use TCP it is displaying as %{host}. Any clue Badger?
thanks in advance.

That suggests that when using a tcp input the [host] field does not exist. That would be strange. I would expect it to be a hash, and the output to contain "{name=1.2.3.4}", or whatever your IP is (unless the name can be looked up).

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.