带有错误时间戳和时间键的日志被忽略

Logs shipped with wrong timestamp and timekey ignored

我想将我的 Vault 日志发送到 s3。基于这个 issue 我这样做了:

## vault input
<source>
  @type tail
  path /var/log/vault_audit.log
  pos_file /var/log/td-agent/vault.audit_log.pos
  <parse>
    @type json
  </parse>
  tag s3.vault.audit
</source>

## s3 output
<match s3.*.*>
  @type s3

  s3_bucket vault
  path logs/

  <buffer time>
    @type file
    path /var/log/td-agent/s3
    timekey 30m
    timekey_wait 5m
    chunk_limit_size 256m
  </buffer>

  time_slice_format %Y/%m/%d/%H%M
</match>

我希望我的日志每 30 分钟发送到 S3,并在目录中格式化为:logs/2019/05/01/1030

相反,我的日志平均每 2-3 分钟发送一次,S3 中的输出时间格式是从纪元开始的,即:logs/1970/01/01/0030_0.gz

(时间在我的系统上设置正确)

这是对我来说效果很好的示例配置。

您需要确保将 time 传递给缓冲区,并尝试明确提供哪种 format

通过检查代理启动日志来检查您的匹配表达式是否正常工作。另外,尝试 <match s3.**>

<match>
  @type s3

  s3_bucket somebucket
  s3_region "us-east-1"
  path "logs/%Y/%m/%d/%H"
  s3_object_key_format "%{path}/%{time_slice}_%{index}.%{file_extension}"
  include_time_key true
  time_format "%Y-%m-%dT%H:%M:%S.%L"

  <buffer tag,time>
    @type file
    path /fluentd/buffer/s3
    timekey_wait 5m
    timekey 30m
    chunk_limit_size 64m
    flush_at_shutdown true
    total_limit_size 256m
    overflow_action block
  </buffer>
  <format>
    @type json
  </format>
  time_slice_format %Y%m%d%H%M%S
</match>