小编efk*_*efk的帖子

使用 rsyslog 将 syslog 消息解析为单独的 MySQL 表

开箱即用的rsyslog会将所有内容转储到SystemEvents`Syslog 数据库中的表中(如果您使用提供的默认架构)。我想使用正则表达式将入站消息过滤到单独的数据库表中。

我玩过这个,但我很难找出实现这一点的最佳方法(甚至是一种起作用的方法)。

在我的 rsyslog.conf 中:

$template wireless, \
 "insert into RogueAPs \
 (ReceivedAt, DeviceReportedTime, Facility, Priority, FromHost, Message) \
 VALUES('%timegenerated%', '%timereported%', '%syslogfacility%', '%syslogpriority%', '%fromhost-ip%', '%msg%');", \ 
 stdsql

if $msg contains 'subtype=wireless' then :ommysql:127.0.0.1,Syslog,dbusername,dbpassword;wireless

*.* :ommysql:127.0.0.1,Syslog,dbusername,dbpassword
Run Code Online (Sandbox Code Playgroud)

这是我最近的尝试,但我被卡住了。

(RogueAPs 表只是 rsyslog 附带的默认 SystemEvents 表的克隆)


版本信息:

shell# /usr/local/sbin/rsyslogd -v
rsyslogd 5.5.5, compiled with:
        FEATURE_REGEXP:                         Yes
        FEATURE_LARGEFILE:                      No
        FEATURE_NETZIP (message compression):   Yes
        GSSAPI Kerberos 5 support:              No
        FEATURE_DEBUG (debug build, slow code): No
        Atomic operations supported:            Yes
        Runtime Instrumentation …
Run Code Online (Sandbox Code Playgroud)

logs rsyslog

10
推荐指数
1
解决办法
5079
查看次数

标签 统计

logs ×1

rsyslog ×1