Method: LogStasher#default_source

Defined in:
lib/logstasher/railtie.rb

#default_sourceObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/logstasher/railtie.rb', line 9

def default_source
  case RUBY_PLATFORM
  when /darwin/
    # NOTE: MacOS Sierra and later are setting `.local`
    # hostnames that even as real hostnames without the `.local` part,
    # are still unresolvable. One reliable way to get an IP is to
    # get all available IP address lists and use the first one.
    # This will always be `127.0.0.1`.
    address_info = Socket.ip_address_list.first
    address_info&.ip_address
  else
    IPSocket.getaddress(Socket.gethostname)
  end
end