I want to forward messages matching a pattern (HELLO
in this case) from a custom log file (/home/ubuntu/test.log
) to a remote rsyslog server.
Here is the configuration:
# cat /etc/rsyslog.d/05-forwarding.conf
*.* @@rsyslogserver.mycompany.com:10514
# cat /etc/rsyslog.d/10-custom.conf
$ModLoad imfile
$InputFilePollInterval 1
$InputFileName /home/ubuntu/test.log
$InputFileTag testlogs:
$InputFileStateFile testlogs
$InputRunFileMonitor
:msg, contains, "HELLO" /var/log/testlog_error.log
& stop
:msg, !contains, "HELLO" stop
Problem:
- All messages going to to the
/var/log/syslog
has stopped. << NOT GOOD - Messages containing
HELLO
word in/home/ubuntu/test.log
are going to/var/log/testlog_error.log
as well as are getting forwarded to remote rsyslog server, << GOOD - Messages NOT containing
HELLO
word in/home/ubuntu/test.log
are not going to/var/log/testlog_error.log
which is GOOD but these messages are getting forwarded to remote rsyslog server. << BAD
My Ideal situation should be:
- System and all other messages should continue to go to
/var/log/syslog
- No Change here. This is working as expected.
- Messages NOT containing
HELLO
word in/home/ubuntu/test.log
should completely get discarded. Don't write to local file as well as don't forward such messages to remote server.
Need help me in solving point 1 and point 3 above.