We've setup a central log server using rsyslog. I was just wondering if it's possible to send the ip address along with the syslog message from the client. I'm sending the message using a template and tried using %fromhost-ip%. As expected it's showing up as on the remote server. So I was wondering is there any way we can embed a bash variable in the rsyslog.conf. The only other alternative I see is to hardcode the ip which doesn't look too nice.

I'm currently using the below template.

$template linux_err,"<%PRI%>%TIMESTAMP% %source% %syslogtag% %smg%"

Guess using the %fromhost-ip% on the receiving server is the only option.

  • 1
    If you use %hostname% on the sender you should get something unique, if you have configured a hostname. Or use %fromhost-ip% in a format template on the server receiving the messages to change the message. – meuh Aug 6 '17 at 13:36

It is clearly written in the documentation that if you are receiving messages from the local system, then you will get as the ip.

Here, http://www.rsyslog.com/doc/master/configuration/properties.html

try sending it from some other system. It works for me.

Or else, if IP is not important to you and you just want to distinguish the host, use %hostname% property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.