here is my updated config; i was trying to extract topic name and output to a file, i was expecting to see topic name to ouput file as part of message , here is the config and output i see, my ultimate objective is to rename the topic name, but for now i would like to atleast see if i can get topic name for later reference in output section
input {
kafka {
bootstrap_servers => "bootstrap:9092"
topics => ["global-heart-beat"]
client_id => "logstash-hostname1"
group_id => "logstash_indexer"
decorate_events => true
add_field => { "[topic_name]" => "%{[@metadata][kafka][topic]}" }
}
}
output {
stdout { codec => rubydebug { metadata => true } }
file {
path => "/var/tmp/logstash.output"
codec => line { format => "custom format: %{message} %{topic_name}" }
}
}
Output: iam expecting to see topic 'global-heart-beat' reflected
$ cat /var/tmp/logstash.output
custom format: msg:hello world %{[@metadata][kafka][topic]}