开发者社区> 问答> 正文

rsyslog 配置mysql输出格式

文档中:
Note rsyslog contains a canned default template to write to the MySQL database. It works on the MonitorWare schema. This template is:
$template tpl,"insert into SystemEvents (Message, Facility, FromHost,
Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values
('%msg%', %syslogfacility%, '%HOSTNAME%', %syslogpriority%,
'%timereported:::date-mysql%', '%timegenerated:::date-mysql%', %iut%,
'%syslogtag%')",SQL
As you can see, the template is an actual SQL statement. Note the ”,SQL” option: it tells the template processor that the template is used for SQL processing, thus quote characters are quoted to prevent security issues. You can not assign a template without ”,SQL” to a MySQL output action.
If you would like to change fields contents or add or delete your own fields, you can simply do so by modifying the schema (if required) and creating your own custom template.

请问如何修改template或者自定义template呢?

展开
收起
蛮大人123 2016-02-07 10:02:56 2609 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪

    定义template:
    $template tpl,"insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg%', %syslogfacility%, '%FROMHOST-IP%', %syslogpriority%, '%timereported:::date-mysql%', '%timegenerated:::date-mysql%', %iut%, '%syslogtag%')",SQL
    设置ommysql后面直接加上 ";tpl" #template name

    2019-07-17 18:38:52
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
深入MySQL实战 立即下载
MySQL 5.7让优化更轻松 立即下载
好的 MySQL 兼容可以做到什么程度 立即下载

相关镜像