rsyslog send specific lines to remote server

Solution 1:

Make it work and writing down the solution if anyone needed in future;

first editrsyslog.conf with nano /etc/rsyslog.conf then add below lines;

#### save hana logs to another file ####
$template hanalog, "/var/log/hanalog"
if $programname contains 'HDB_SYSTEMD' then ?hanalog
& ~

after adding lines your config file should like this; config file preview

then edit rsyslog.d file as nano /etc/rsyslog.d/hana-log.conf and add below template;

$ModLoad imfile    #Load the imfile input module

$InputFilePollInterval 10

$InputFileName  /var/log/hanalog

$InputFileTag hana-dberisim:

$InputFileStateFile stat-hana-dberisim

$InputFileSeverity Info

$InputRunFileMonitor


$template hana_dberisim, "  %msg% "


if $programname == 'hana-dberisim' then @remote_server_ip:port;hana_dberisim

if $programname == 'hana-dberisim' then stop

restart rsyslog service;

service rsyslog restart

Thats all.