2016-08-23 61 views
1

樣品JSON配置模板: 我想改變日期格式爲UTC統一TZ針對不同客戶更改時區爲UTC在rsyslog現在配置

template(name="json-template" type="list") { 
    constant(value="{") 
    constant(value="\"@timestamp\":\"") 
    property(name="timereported" dateFormat="rfc3339") 
    constant(value="\",\"@version\":\"1") 
    constant(value="\",\"message\":\"") 
    property(name="msg" format="json") 
    constant(value="\",\"sysloghost\":\"") 
    property(name="hostname") 
    constant(value="\",\"severity\":\"") 
    property(name="syslogseverity-text") 
    constant(value="\",\"facility\":\"") 
    property(name="syslogfacility-text") 
    constant(value="\",\"programname\":\"") 
    property(name="programname") 
    constant(value="\",\"procid\":\"") 
    property(name="procid") 
    constant(value="\"}\n") 
} 

回答

0

如果你知道的時區,你可以在此做方法:

template(name="json-template" type="list") { 
constant(value="{") 
constant(value="\"@timestamp\":\"") 
property(name="timereported" dateFormat="year") 
constant(value="-") property(name="timereported" dateFormat="month") 
constant(value="-") property(name="timereported" dateFormat="day") 
constant(value="T") property(name="timereported" dateFormat="hour") 
constant(value=":") property(name="timereported" dateFormat="minute") 
constant(value=":") property(name="timereported" dateFormat="second") 
constant(value="+00:00") 
... 

如果你想,該時間將重新計算你的時區,然後在這裏看到:

http://www.rsyslog.com/doc/v8-stable/configuration/templates.htmlhttp://www.rsyslog.com/doc/v8-stable/configuration/property_replacer.html

或源代碼:

https://github.com/rsyslog/rsyslog/blob/master/runtime/msg.c

,並使用-utc funtions例如:現在-UTC,今年UTC, ...

祝你好運

Erwin