Display hostname instead of 127.0.0.1


(Saeid) #1

Currently the "host" field in our logs always is "127.0.0.1". We want it to be either the "hostname" or the actual ip of the current machine. How can I achieve that?


(Saeid) #2

Found the solution. The only way I could get it to work was by using ruby.
It's quite easy actually. Just add the following code as a filter:

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