【问题标题】:filebeat @timestamp not overwrittenfilebeat @timestamp 未被覆盖
【发布时间】:2017-09-06 11:59:33
【问题描述】:

我使用filebeat 将日志写入elasticsearch 服务器。我的日志是 json 格式。每一行都是一个json字符串,看起来像这样

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

我希望我的日志中的 @timestamp 字段替换 filebeat 在读取日志时创建的 @timestamp 字段。在我的 kibana 仪表板上,我总是得到

json_error:@timestamp 未被覆盖(2017-04-11T07:52:48,230 解析错误)

最后看到由 filebeat 创建的 @timestamp 字段

我的 filebeat conf 包含关于覆盖字段的那些行

json.keys_under_root: true
json.overwrite_keys: true
json.add_error_key: true

同样来自我的log4j conf,在我的日志中创建的@timestamp 字段采用ISO8601 格式。知道问题出在哪里以及为什么 @timestamp 字段没有被覆盖?

【问题讨论】:

    标签: json elasticsearch logstash kibana filebeat


    【解决方案1】:

    问题在于log4j 生成的时间戳格式。 Filebeat 需要 "2017-04-11T09:38:33.365Z" 形式的东西,它必须必须在中间 T 最后 Z 和毫秒前的点而不是逗号。

    我发现最快(但有点脏)的方法是使用以下模式

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

    可以在here 找到类似的问题。建议的解决方案无法解决文件节拍问题,因为它使用逗号!

    【讨论】:

      猜你喜欢
      • 2023-02-03
      • 1970-01-01
      • 2021-12-18
      • 2018-03-02
      • 1970-01-01
      • 1970-01-01
      • 2022-11-30
      • 1970-01-01
      • 2023-03-14
      相关资源
      最近更新 更多