2017-04-11 145 views
1

我用filebeat將日誌寫入elasticsearch服務器。我的日誌採用json格式。每一行是一個JSON字符串,看起來像這樣filebeat @timestamp沒有被覆蓋

{"@timestamp": "2017-04-11T07:52:480,230", "user_id": "1", "delay": 12} 

我想從我的日誌@timestamp場更換@timestamp場讀取日誌時filebeat創建。在我kibana儀表盤我總是

json_error:@timestamp not overwritten (parse error on 2017-04-11T07:52:48,230)

,並最終看到由filebeat

我filebeat的conf創建@timestamp領域包括關於覆蓋領域

json.keys_under_root: true 
json.overwrite_keys: true 
json.add_error_key: true 
從我 log4j的conf

而且這些線在我的日誌中創建的@timestamp字段格式爲ISO8601。任何想法是什麼問題以及爲什麼@timestamp字段沒有被覆蓋?

回答

0

問題是log4j產生的時間戳的格式。 Filebeat需要的形式"2017-04-11T09:38:33.365Z"必須在最後Z中間有T,並且在毫秒之前使用點而不是逗號。

最快(和有點髒)的方式,我發現這樣做是通過以下方式

pattern='{"@timestamp": "%d{YYYY-MM-dd}T%d{HH:mm:ss.SSS}Z"} 

類似的問題可以發現here。建議的解決方案不能解決filebeat問題,因爲它使用逗號!