fangli / fluent-plugin-influxdb

A buffered output plugin for fluentd and InfluxDB
MIT License
111 stars 65 forks source link

Disordered writes in a connection-faiilure environment #67

Closed sabueso closed 7 years ago

sabueso commented 7 years ago

Hi!

I'm trying to insert in some sequentials writes in InfluxDB comming from a "not stable connection environment". Td-agent, basically reads from rabbitmq, and insert into a measurement schema. The configuration in the server side is this:

<source>
  @type amqp
  host localhost
  port 5672
  vhost /
  user admin
  pass mypass
  queue health_info
  format json
  durable true
  tag_key true
</source>

<match **>
  @type influxdb
  dbname health
  user admin
  password mypass
  use_ssl false
  retry 0
  num_threads 1
  sequence_tag _seq
</match>

The problem comes when i cut off the connection between my client and server: when RabbitMQ is reconnected, all the stored messages pass between host and server in order, and they are diferents (they have an additional "timestamp" field) but they are written totally disordered at InfluxDB

Some example messages:

{"disk_usage": 2, "cpu_usage": 1.0, "percent_mem": 20.9, "disk_percent": 57.7, "used_mem": 193, "timestamp": "2017-01-07T17:41:32Z"}
{"disk_usage": 2, "cpu_usage": 0.5, "percent_mem": 20.9, "disk_percent": 57.7, "used_mem": 193, "timestamp": "2017-01-07T17:41:42Z"}

Some considerations: a) This is not happening when connection is not cutted off between AMQP server altough you're writing these at InfluxDB. All messages are written in order. b) RabbitMQ is passing once message (line) at time. c) If i replace InfluxDB for file output plugin, this works correctly and all lines are written sequentially onto the file, as we were passed across.

Can this be a bug? Thanks!

repeatedly commented 7 years ago

I'm not sure this is a bug of influxdb plugin because influxdb output plugin simply sends incoming records into influxdb. This is same as file output plugin. Maybe, you need to check which point causes disorderd problem.

sabueso commented 7 years ago

I'm trying to enable some debug traces to see what's happening. Thanks for your help, i'll keep this ticket updated.

sabueso commented 7 years ago

A note i forgot make. Once the insertions becomes"disordered", they don't stop until you restart td-agent.

> select * from virtualbubuntu
name: virtualbubuntu
time            _seq    cpu_usage   disk_percent    disk_usage  percent_mem timestamp       used_mem    value
----            ----    ---------   ------------    ----------  ----------- ---------       --------    -----
1483819528000000000 0   0.5     57.7        2       21      2017-01-07T20:06:22Z    194     
1483819528000000000 2   0.5     57.7        2       21      2017-01-07T20:06:32Z    194     
1483819548000000000 1   1       57.7        2       21      2017-01-07T20:06:42Z    194     
1483819548000000000 2   1       57.7        2       21      2017-01-07T20:06:52Z    194     
1483819568000000000 0   1       57.7        2       21      2017-01-07T20:07:02Z    194     
1483819568000000000 2   0.5     57.7        2       21      2017-01-07T20:07:12Z    194     
1483819588000000000 0   2       57.7        2       21      2017-01-07T20:07:22Z    194     
1483819588000000000 1   1       57.7        2       21      2017-01-07T20:07:32Z    194     
1483819608000000000 2   1.5     57.7        2       21      2017-01-07T20:07:52Z    194     
1483819608000000000 1   1       57.7        2       21      2017-01-07T20:07:42Z    194
sabueso commented 7 years ago

I'm going to close this ticket, my problem is fixed, and i'll write some considerations before do this:

-Maybe, i missunderstood about how InfluxDB works, writing and showing data.

-I resolved my problem specifing a timestamp from origin BUT If you specify "time" as timestamp value for time value, for some reason, is not used, dropped, and inserted with insertion timestamp. I don't know if this is a bug, of if this comes from the broker (RabbitMQ in my case).-

Thanks for you help!