【问题标题】:fluentd in_http plugin give wrong timefluentd in_http 插件给出错误的时间
【发布时间】:2017-08-07 18:25:42
【问题描述】:

这是我的配置:

<source>
  @type http
  port 8080
  bind 0.0.0.0
  body_size_limit 1m
  keepalive_timeout 20s
  cors_allow_origins ["http://example.net"]
  add_remote_addr true
</source>

<match log>
  @type sql
  host 127.0.0.1
  port 3306
  database user
  adapter mysql2
  username user
  password pass
  socket /var/run/mysqld/mysqld.sock
  flush_interval 1s
  num_threads 2
  <table>
    table http_logs
    column_mapping 'timestamp:created_at,REMOTE_ADDR:ip,name:name,value:value,value2:value2,url:url'
  </table>
</match>

我正在将数据发送到 mysql, mysql 和 fluentd 服务器使用相同的时间和时区,但 fluentd 总是将时间向后发送 3 小时,所以如果实际时间是

root@fluentd:~# date
Mon Aug  7 21:22:04 IDT 2017

fluentd 正在插入新数据,时间为:

2017 年 8 月 7 日星期一 18:22:04 IDT

我查看了 fluentd 输入和输出插件,但没有时区配置

【问题讨论】:

    标签: fluentd


    【解决方案1】:

    我认为发生的事情是 fluentd 将您的时间戳转换为 UTC 格式(没有时区),之后 mysql 将 UTC 时间格式转换为 GMT+0 可能距您的时区 -3 小时。

    你可以像example这样配置流利的时区:

    <match pattern>
      type file
      path /var/log/fluent/myapp
      time_slice_format %Y%m%d
      time_slice_wait 10m
      time_format %Y%m%dT%H%M%S%z
      timezone +08:00
    </match>
    

    【讨论】:

    • 我收到 [警告]: 中的参数“时区”。我猜@type sql 只是不支持这个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-22
    • 1970-01-01
    • 2021-10-27
    • 2021-07-08
    • 1970-01-01
    相关资源
    最近更新 更多