Mac hostname showing as "localhost"

I've been running into an interesting issue and it sounds like in the past there was a similar challenge running a beat on a mac. In my case this is filebeat, but the symptom is the same as @DPattee reported here:

I'm using a launchDaemon to start filebeat at system startup. When this happens machines seem to want to report back "localhost" as the machine name via filebeat even though all other system tools show the proper hostname.

Sure enough, as soon as I kill filebeat (and it re-launches) the proper hostname begins reporting back. I wasn't sure if anyone has put together a workaround other than restarting the agent, but wanted to share one I've done:

As part of the filebeat install we run a postinstall script to add in and load the launchDaemon. I added in a line of code to:

echo "name: "hostname | cut -d "." -f1 >> /usr/local/filebeat/filebeat.yml

This puts sets what eventually appears as to the machine name trimming out .local and stores the data into the filebeat.yml config file.

Hope this helps some and if there are some better ways I'm happy to hear!

Probably the beat is starting before the networking system is fully up. I think all Beats only retrieve the hostname once at startup. It might make sense to have to Beat periodically check to see if the hostname has changed.

This topic was automatically closed after 21 days. New replies are no longer allowed.