【发布时间】:2019-05-06 23:01:16
【问题描述】:
我正在尝试将非标准 syslog 格式的应用程序日志导入 mysql。
示例行:
Dec 5 10:50:06 wifi coova-chilli[10099]: Client process timed out: 2
当我使用 imfile 模块导入日志(然后将其转发到 mysql)时,它工作正常,但整行都进入了消息字段。这也意味着 ReceivedAt 和 DeviceReportedTime 字段是导入日志时的时间戳,而不是消息中的实际事件时间。
我认为答案在于属性替换器,但我似乎无法在网上找到有关如何实际获取实际日期并将其强制放入 DeviceReportedTime 字段的示例。
这就是数据库中的最终结果:
53052 NULL 2018-12-04 16:17:44 2018-12-04 16:17:44 16 5 server Dec 5 10:50:06 wifi coova-chilli[10099]: Client process timed out: 2 5 NULL customtag NULL NULL 0 NULL NULL NULL NULL NULL 3 customtag - NULL NULL
我在 /etc/rsyslog.d 中的客户端有以下配置:
module(load="imfile" mode="inotify")
input(type="imfile"
File="/var/log/appname/applog.log"
Tag="customtag")
这在服务器端的 /etc/rsysconfig.d 下:
:syslogtag, contains, "customtag":ommysql:10.255.2.6,rsyslogdb,loganalyzer,password
【问题讨论】:
标签: linux logging centos7 rsyslog