Skip to content

Instantly share code, notes, and snippets.

@chiraggude
Last active September 7, 2023 02:01
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chiraggude/5b727f75ac7150c032fe to your computer and use it in GitHub Desktop.
Save chiraggude/5b727f75ac7150c032fe to your computer and use it in GitHub Desktop.
Rsyslog Client nginx conf
$ModLoad imfile
$InputFilePollInterval 10
$PrivDropToGroup adm
#NGINX access file:
# Path to the file which you want to monitor
$InputFileName /home/logs/nginx-access.log
# The tag apache can be changed to whatever you'd like note this is referenced in the if $programname
# It can be used as %app-name% in template. We can also use %syslogtag% but it also returns ":"
$InputFileTag nginx-access:
# Name of spool file when remote server is not reachable
$InputFileStateFile stat-nginx-access
# Priority of Syslog event. Can be used as %syslogpriority% in template
$InputFileSeverity info
# https://community.loggly.com/customer/portal/articles/1225986-rsyslog-configuration-for-file-monitoring
$InputRunFileMonitor
#NGINX Error file:
$InputFileName /home/logs/nginx-error.log
$InputFileTag nginx-error:
$InputFileStateFile stat-nginx-error
$InputFileSeverity error
$InputRunFileMonitor
#PHP Error file:
$InputFileName /home/logs/php-error.log
$InputFileTag php-error:
$InputFileStateFile php-nginx-error
$InputFileSeverity error
$InputRunFileMonitor
#Add a tag for apache events
$template CPGLogFormat,"%HOSTNAME% %syslogpriority% %syslogfacility% %app-name% %msg% \n"
# The @@ in the last line of the configuration tells rsyslog to send data via TCP. Use @ for UDP
if $programname == 'nginx-access' then @185.38.44.97:514;CPGLogFormat
if $programname == 'nginx-access' then stop
if $programname == 'nginx-error' then @185.38.44.97:514;CPGLogFormat
if $programname == 'nginx-error' then stop
if $programname == 'php-error' then @185.38.44.97:514;CPGLogFormat
if $programname == 'php-error' then stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment