linux - 如何将部分时间戳添加到 Fluentd 输出文件格式

标签 linux logging amazon-s3 fluentd

如何将时间戳的特定部分添加到 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 的新手。

最佳答案

这是正确的链接: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>

关于linux - 如何将部分时间戳添加到 Fluentd 输出文件格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47643251/

相关文章:

c - 如何通过线程将数组作为返回值传递?

我们可以通过 mmap() 分配物理上连续的内存吗?

logging - Heroku:如何检查 Heroku 错误日志?

java - logback-spring.xml 不会附加文件名

angularjs - AWS S3 NodeJS 禁止或连接休息

amazon-web-services - 每次将文件发布到存储桶时都将 s3 文件复制到 ec2 吗?

ios - 使用 AWS 的 Swift 显示 UIImageView

python - 让弹出窗口居中于父窗口 - Glade、GTK、Python

linux - 如何使用纯命令行命令复制 putty ssh 隧道设置?

java - 如何使用 log4j 禁用 PubNub 的 okhttp3.internal.platform.Platform.log?