【问题标题】:Parsing time key with nanoseconds用纳秒解析时间键
【发布时间】:2019-05-12 16:09:05
【问题描述】:

我有以下时间密钥:"2019-05-12T14:52:13.136621898Z"

我无法弄清楚 time_format 来解析这个。我试过:"%Y-%m-%dT%H:%M:%S.%NZ" 根据我的理解应该可以工作。当我用它解析时,我的日志是从纪元开始存储的,这表明解析失败。

【问题讨论】:

    标签: fluentd


    【解决方案1】:

    如果您使用earlier 问题中提供的配置,则在sourceparse 部分中,指定time_format 模式,该模式应负责根据您的输入文件时间创建文件

    这是source 配置示例。

    <source>
      @type dummy
      tag dummy
      dummy [
        {"message": "blah","time":"2019-05-12T14:52:13.136621898Z"}
      ]
      <parse>
        @type json
        time_format "%Y-%m-%dT%H:%M:%S.%NZ"
      </parse>
    </source>
    
    <match dummy>
      @type stdout
    </match>
    

    如果您的输入时间使用不同的 JSON 键名,则另外提供 time_key

    {"message": "blah","mytimekey":"2019-05-12T14:52:13.136621898Z"}

    time_key mytimekey

    https://docs.fluentd.org/v1.0/articles/parse-section#parse-parameters

    【讨论】:

      猜你喜欢
      • 2019-08-01
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-20
      • 2017-02-15
      • 2021-09-27
      • 1970-01-01
      相关资源
      最近更新 更多