How to get hostname from host.name field and put it in execute command in Logstash output?

Hello dears,

Log sample:

Logstash.conf:

filter {
     
    if 'java.net.ConnectException: Connection refused (Connection refused)' in [message] {
     mutate {
       add_field => {"document_id" => "%{[@metadata][_id]}"}
       add_field => {"body"        => "%{context_message}"}
       gsub => [
	"context_message", "'", ""
       ]
       code => 'puts event.get("context_message")'
     }
    }
    else { drop{} }
    
}

output {
        exec {
              command => "/tmp/netcool_insert %{document_id} elastic 4 '%{context_message}'" 
             }

}

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