First you need to vim /etc/rsyslog.conf , and add the line $ModLoad imfile to the bottom of the Modules section. This loads the module we need for pushing bespoke logs through rsyslog.
Create the file /etc/rsyslog.d/graylog.conf` Contents look like this:
# Now load the external log for Graylog $InputFileName /var/log/graylog-server/server.log $InputFileTag graylog $InputFileStateFile ms $InputFileSeverity debug $InputFileFacility local0 $InputRunFileMonitor local0.@127.0.0.1:1514;RSYSLOG_SyslogProtocol23Format*
# Now load the external log for MongoDB $InputFileName /var/log/mongodb/mongod.log $InputFileTag mongodb $InputFileStateFile ms $InputFileSeverity debug $InputFileFacility local1 $InputRunFileMonitor local1.@127.0.0.1:1514;RSYSLOG_SyslogProtocol23Format*
# Now load the external log for elasticsearch $InputFileName /var/log/elasticsearch/.log* $InputFileTag elasticsearch $InputFileStateFile ms $InputFileSeverity debug $InputFileFacility local2 $InputRunFileMonitor local2.@127.0.0.1:1514;RSYSLOG_SyslogProtocol23Format*
Restart Rsyslog for this to take effect. These logs will now be sent (in this example) to port 1514.
You will need to set the permissions on these logs files in the /var/log folder so that rsyslog has permission to read them.
However. I would recommend you instead install filebeats locally, and configure filebeats to ingest these logs and foward them to Graylog.
You should get some kind of error back if rsyslog isn’t runing - doesn’t have permissions to access the logs, or if there is a syntax error in the config file etc
You can test the Graylog input is working by manually sending a message to the input from the terminal
I ran service rsyslog status and findout some errors in graylog.conf file.
This is how I changed it, and now it’s working:
replace lines 8, 17, and 26 with