Hostname-Lookup
logstash-gelf contains a class (biz.paluch.logging.RuntimeContainer) which performs a hostname resolution on the first use of the framework. This can take some time, especially, when your DNS is not set up for all host addresses.
The lookup is performed in that way:
- Retrieve all
InetAddresses from allNetworkInterfaces - Skip
LoopbackAdresses - Skip all
InetAddresses which cannot be resolved to a FQDN (HostAddressequalsCanonicalHostName) - Use first
InetAddressthat passes that rules. - If none passes, use
LocalHostInetAddress - If the lookup fails, hostname and FQDN hostname will be set to “unknown”
You can take control over the lookup order. Sometimes your host's have a real address on the localhost but a cluster name on the network devices and sometimes the other way arournd.
Controlling lookup order
You can provide a system property, logstash-gelf.resolutionOrder to control the lookup order.
- Use
localhost,networkfor: First inspect the localhost name, then try to get the host name from network devices. - Use
network,localhostfor: First inspect the network devices to retrieve a hos name, then try to get the hostname from the localhost (default).
Bypassing Hostname-Lookup
You can bypass that process by setting some SystemProperties. Set logstash-gelf.skipHostnameResolution to true to bypass the resolution. If you've set the originHost property on
your logger, so the properties value will be used anyway. If you didn't set the originHost property, and lookup is disabled, the value “unknown” will be used as hostname.
Default/Fallback Values for Hostname-Lookup
- Set
logstash-gelf.hostnameto use a fixed hostname (simple). This property can be handy in case the lookup runs into IO Exceptions. - Set
logstash-gelf.fqdn.hostnameto use a fixed hostname (fully qualified). This property can be handy in case the lookup runs into IO Exceptions.
See Javadoc for further details.
