【问题标题】:Fluentd time_key setting not workingFluentd time_key 设置不起作用
【发布时间】:2017-04-18 15:39:24
【问题描述】:

正在尝试使用 fluentd 将 mysql 日志集中到弹性搜索中。

我看到的问题是搜索中的时间戳与日志中的时间戳不匹配。

这是我的流利配置:

<source>
  @type tail
  path /logs/mysql/audit.log
  pos_file /var/log/td-agent/audit.log.pos
  tag mysql.audit
  format json
</source>

<match mysql.audit>
  type elasticsearch
  host isolinear-eg.corp.apple.com
  port 9200
  index_name mysql_audit
  include_tag_key true
  logstash_format true
  logstash_prefix mysql_audit
  time_key audit_record.timestamp
  time_format %Y-%m-%dT%H:%M:%S %Z
  flush_interval 10s # for testing
</match>

这是输出:

{
  "_index": "mysql_audit-2017.04.18",
  "_type": "fluentd",
  "_id": "AVuBrutMy6H0rNsJZZHy",
  "_score": null,
  "_source": {
    "audit_record": {
      "name": "Connect",
      "record": "447474053_2017-04-11T22:30:21",
      "timestamp": "2017-04-18T15:29:01 UTC",
      "connection_id": "21450",
      "status": 0,
      "user": "solver",
      "priv_user": "solver",
      "os_login": "",
      "proxy_user": "",
      "host": "",
      "ip": "10.108.251.201",
      "db": "solver"
    },
    "tag": "mysql.audit",
    "@timestamp": "2017-04-18T10:29:02-05:00"
  },
  "fields": {
    "@timestamp": [
      1492529342000
    ]
  },
  "sort": [
    1492529342000
  ]
}

我看到的问题是时间戳与审计记录时间戳不匹配。

【问题讨论】:

    标签: elasticsearch record fluentd transformer


    【解决方案1】:

    例如,生成的日志本身就有一个时间键。 example log format

    我们需要在源代码部分提供 time_key 键。

    <source>
      @type tail
      path /logs/mysql/audit.log
      pos_file /var/log/td-agent/audit.log.pos
      time_key time
      tag mysql.audit
      format json
    </source>
    

    如果 time_key 不在日志中。 fluentd 会将它的日志读取时间附加到日志中。

    您没有在源部分指定 time_key。这就是为什么 fluentd 没有考虑实际的日志时间

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-07
      • 1970-01-01
      • 2015-12-17
      • 2016-08-15
      • 2011-04-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多