I have set up a central remote syslog server where I am sending all my logs. There will be many machines logging to the syslog server. On the client machine, in the rsyslog.conf I am trying to modify the host name. I know I can use the following to change the loggers host name.
$LocalHostName foo
However I want to be able to able to dynamically modify the Local hostname based on some environment variable.
if [[ -z $FOO ]]; then
$LocalHostName "$FOO foo"
else
$LocalHostName "$FOO foo"
fi
rsyslog take the literal string "$FOO foo"
as the new hostname.
I also have the option of writing a script that can modify the rsyslog.conf file and updates the localhostname value. However is there some way to dynamically generate hostnames in rsyslog?