【问题标题】:Losing data between fluentd and influxdb在 fluentd 和 influxdb 之间丢失数据
【发布时间】:2015-11-27 03:58:30
【问题描述】:

我正在努力解决 fluentd 和 influxdb 之间的数据丢失问题。

在此配置下使用 fluent-plugin-influxdb 插件:

<source>
  id test_syslog
  type syslog
  port 42185
  protocol_type tcp
  time_format %Y-%m-%dT%H:%M:%SZ
  tag test_syslog
  format /^(?<time>[^ ]*) (?<fastly_server>[^ ]*) (?<log_name>[^ ]*) (?<host>[^ ]*) ([^ ]*) ([^ ]*) (?<http_method>[^ ]*) (?<http_request>[^ ]*) (?<http_status>[^ ]*) (?<cache_status>[^ ]*) (?<uuid>[^ ]*) *(?<device_model>.*)$/
</source>

<match test_syslog.**>
  type copy
  <store>
    type file
    path /var/log/td-agent/test_syslog
  </store>
  <store>
    id test_syslog
    type influxdb
    dbname test1
    flush_interval 10s
    host localhost
    port 8086
    remove_tag_suffix .local0.info
  </store>
</match>

比较文件输出和 influxdb 中的数据时,我发现:

user@ip-xxx-xxx-xxx-xxx:/var/log/td-agent# curl -G 'http://localhost:8086/query' --data-urlencode "db=test1" --data-urlencode "q=SELECT COUNT(host) FROM log_data" ; cat test_syslog.20150901.b51eb4653c54c63e7 | wc -l
{"results":[{"series":[{"name":"log_data","columns":["time","count"],"values":[["1970-01-01T00:00:00Z",582]]}]}]}2355

日志中有 2355 行,但数据库中只有 582 条记录。

我已启用来自 influxdb 和 fluentd 的调试/跟踪日志记录,但目前日志中没有任何有趣的内容。

有什么想法吗?

【问题讨论】:

  • 也许你在写重复的点?如果测量名称、标签集和时间戳匹配,则新点会静默覆盖先前的点。此外,它可能是版本不匹配。 InfluxDB API 最近发生了关于整数的重大更改,并且该插件可能尚未更新以处理该问题。 InfluxDB 日志是否显示失败的写入?

标签: influxdb fluentd


【解决方案1】:

本周刚刚偶然发现了这个问题。 就我而言,由于重复的点,日志会丢失。

我正在使用 fluentd v0.12,它只支持精确到秒。较新版本中提供了亚秒级精度,请参阅https://github.com/fluent/fluentd/issues/461。因此,使用相同的标签和相同的时间戳进行相同的测量是很容易的

解决方案是使用 influxdb 类型中的“sequence_tag”,如:

  @type influxdb
  host {{INFLUXDB_HOST}}
  port {{INFLUXDB_PORT}}
  dbname {{INFLUXDB_DBNAME}}
  sequence_tag sequence  

具有相同时间戳的记录将有一个额外的标签,如:

time                 requestDurationMillis sequence success testClients testGroup    testRunId
----                 --------------------- -------- ------- ----------- ---------    ---------
2018-01-17T11:09:13Z 530                   0        1       2           warmup       20180117/130908
2018-01-17T11:09:13Z 529                   1        1       2           warmup       20180117/130908

【讨论】:

  • 非常好的解决方案!不管分辨率如何,这将确保没有任何东西丢失。
  • 这对标签基数不会不利吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-27
  • 1970-01-01
  • 2020-07-08
相关资源
最近更新 更多