【问题标题】:Rsyslog to PostgreSQL works fine but not all columns are filled到 PostgreSQL 的 Rsyslog 工作正常,但并非所有列都已填充
【发布时间】:2020-02-19 20:06:38
【问题描述】:

我正确配置为将系统日志消息存储在 PostgreSQL 中,如图所示,但 ntseverity、重要性、事件源等为空:

这是我到现在为止的配置:

## Configuration file for rsyslog-pgsql
### Changes are preserved

module (load="ompgsql")
*.* action(type="ompgsql" server="localhost" db="syslog" uid="rsyslogu" pwd="*********")

似乎必须创建一个模板,如下所示: https://www.rsyslog.com/doc/v8-stable/configuration/modules/ompgsql.html

如何为要填充的额外列设置模板? 有人在模板中有剩余的列吗?

template(name="sql-syslog" type="list" option.sql="on") {
  constant(value="INSERT INTO SystemEvents (message, timereported) values ('")
  property(name="msg")
  constant(value="','")
  property(name="timereported" dateformat="pgsql" date.inUTC="on")
  constant(value="')")
}

【问题讨论】:

    标签: postgresql rsyslog


    【解决方案1】:

    您的字段为空,因为在插入语句中您只发送了两个字段。

    试试类似的东西:

    $template SQLWithProcessID,"insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg:R,ERE,1,FIELD:([a-zA-Z\/]+)(\[[0-9]{1,5}\])*:--end%', %syslogfacility%, '%HOSTNAME%', %syslogpriority%, '%timereported:::date-pgsql%', '%timegenerated:::date-pgsql%', %iut%, '%syslogtag:R,ERE,1,FIELD:([a-zA-Z\/]+)(\[[0-9]{1,5}\])*:--end%')",sql
    
    module(load="ompgsql")
    *.* :ompgsql:10.40.30.10,rsyslog,rsyslog,rsyslog;SQLWithProcessID 
    

    【讨论】:

    猜你喜欢
    • 2019-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-21
    • 2017-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多