Logstash hostname as field

Hi all,
Just wondering how can i get the logstash hostname as field in a clustered environment? all i can see is the hostname of beats. TIA

You can do this using a ruby script within a filter. See the answer https://discuss.elastic.co/t/how-can-i-get-the-logstash-hostname/51771:

filter {
  ruby {
    init => "require 'socket'"
    code => "event['some-field-name'] = Socket.gethostname"
  }
}
1 Like

Hi, It works. I just change it to

ruby {
init => "require 'socket'"
code => "event.set('some field', Socket.gethostname)"
}

Thank you so much!

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