我想将MongoDB日志发送到Graylog服务器,相关的rsyslog配置如下:
$InputFileName /var/log/mongodb/mongod_27017.log
$InputFileTag mongodb
$InputFileStateFile mongodb-state
$InputFileFacility local3
$ActionSendTCPRebindInterval 10000
$InputRunFileMonitor
template(name="TAPSI_JSONFmt" type="string" string="{\"message\":\"%msg:::json%\",\"source\":\"%HOSTNAME:::json%\",\"timestamp\":\"%timegenerated:::date-rfc3339%\"}")
:msg, contains, "Slow query" {
local3.* action(type="omfwd" template="TAPSI_JSONFmt" target="graylog.tapsi.tech" port="12205" protocol="tcp" action.resumeRetryCount="100" queue.type="linkedList" queue.size="100")
}
如下rsyslog.conf
:
# /etc/rsyslog.conf configuration file for rsyslog
#
# For more information install rsyslog-doc and see
# /usr/share/doc/rsyslog-doc/html/configuration/index.html
#
# Default logging rules can be found in /etc/rsyslog.d/50-default.conf
#################
#### MODULES ####
#################
module(load="imuxsock") # provides support for local system logging
#module(load="immark") # provides --MARK-- message capability
# provides UDP syslog reception
#module(load="imudp")
#input(type="imudp" port="514")
# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")
# provides kernel logging support and enable non-kernel klog messages
module(load="imklog" permitnonkernelfacility="on")
###########################
#### GLOBAL DIRECTIVES ####
###########################
#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# Filter duplicated messages
$RepeatedMsgReduction on
#
# Set the default permissions for all log files.
#
$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PrivDropToUser syslog
$PrivDropToGroup syslog
#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog
#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf
现在我遇到的问题是 MongoDB 日志未发送到 Graylog 服务器,并且出现此错误:
Jun 01 15:57:15 Asia-DB-Mongo-Chilli-Able rsyslogd[50679]: cannot connect to graylog.tapsi.tech:12205: Connection timed out [v8.2001.0 try https://www.rsyslog.com/e/2027 ]
Jun 01 15:57:15 Asia-DB-Mongo-Chilli-Able rsyslogd[50679]: action 'action-3-builtin:omfwd' suspended (module 'builtin:omfwd'), retry 0. There should be messages before this one giving the reason for suspension. [v8.2001.0 try https://www.rsyslog.com/e/2007 ]
我不知道问题到底是什么以及我该如何解决这个问题。