rsyslog接收日志写入mysql配置

$EscapeControlCharactersOnReceive off

$template TraditionalFormat2,"%msg%\n"
$template TraditionalFormat3,"%syslogtag% %msg%\n"
$template TraditionalFormat4,"%syslogtag% %msg%\n"
$template StdSQLFormat,"insert into bi_action(id,serverId,`date`,`%msg:R,ERE,1,DFLT:\w+ \w+ (\w+)--end%`) values(%msg:R,ERE,1,DFLT:(\w+)--end%,%msg:R,ERE,1,DFLT:\w+ (\w+) \w+--end%,%$year%%$month%%$day%,1) on duplicate key update `%msg:R,ERE,1,DFLT:\w+ \w+ (\w+)--end%`=`%msg:R,ERE,1,DFLT:\w+ \w+ (\w+)--end%`+1  ",SQL



        if re_match($syslogtag,'^moon[0-9]+-[a-zA-Z_]+.log$') then {
                $ActionFileDefaultTemplate TraditionalFormat2
                $template DynFile2,"/opt/logs/router-log/%syslogtag:R,ERE,1,DFLT:(.*)-.*.log--end%/%timegenerated:1:10:date-rfc3339%/%syslogtag:R,ERE,1,DFLT:.*-(.*).log--end%.log"
                *.* -?DynFile2
                $ModLoad ommysql
                *.* :ommysql:127.0.0.1,Syslog,root,
                stop
        } else if re_match($syslogtag,'^moon[0-9]+$') then {
                        $ActionFileDefaultTemplate TraditionalFormat3
                        $template DynFile3,"/opt/logs/router-log/moon-alert.log"
                        *.* -?DynFile3
                        stop
        } else if re_match($syslogtag,'^moon[0-9]+\\-BI$') then {
                        $ActionFileDefaultTemplate TraditionalFormat4
                        $template DynFile4,"/opt/logs/router-log/moon-BI.log"
                        *.* -?DynFile4
                        *.*     >127.0.0.1,Syslog,root,;StdSQLFormat

                        stop
        }
发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>