【问题标题】:How to add portion of timestamp to Fluentd output file format如何将时间戳的一部分添加到 Fluentd 输出文件格式
【发布时间】:2017-12-04 22:49:01
【问题描述】:

如何将时间戳的某些部分添加到 fluentd 生成的输出文件中?

在配置文件中: s3_object_key_format generic-logs/%{time_slice}/out-%{H}-%{M}-%{S}-%{index}.log

time_slice_format %Y/%m/%d

我期望的例如:out-21-15-45-02.log

我得到了什么:out-%H-%M-%S-02.log

注意:我是 fluentd 的新手。

【问题讨论】:

    标签: linux logging amazon-s3 fluentd


    【解决方案1】:

    此链接来自:fluent-plugin-s3

    我目前正在使用这种精确的格式,它在 s3 中正确地制作了日期时间戳。

    <match pattern>
      @type s3
    
      aws_key_id YOUR_AWS_KEY_ID
      aws_sec_key YOUR_AWS_SECRET_KEY
      s3_bucket YOUR_S3_BUCKET_NAME
      s3_region ap-northeast-1
    
      path logs/${tag}/%Y/%m/%d/
      s3_object_key_format %{path}%{time_slice}_%{index}.%{file_extension}
    
      # if you want to use ${tag} or %Y/%m/%d/ like syntax in path / s3_object_key_format,
      # need to specify tag for ${tag} and time for %Y/%m/%d in <buffer> argument.
      <buffer tag,time>
        @type file
        path /var/log/fluent/s3
        timekey 3600 # 1 hour partition
        timekey_wait 10m
        timekey_use_utc true # use utc
      </buffer>
      <format>
        @type json
      </format>
    </match>
    

    【讨论】:

      猜你喜欢
      • 2014-01-01
      • 2014-02-23
      • 1970-01-01
      • 2011-02-05
      • 1970-01-01
      • 2023-01-06
      • 2016-10-04
      • 2017-10-22
      • 2014-02-01
      相关资源
      最近更新 更多