telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

Wrong timestamps with mongodb plugin

Open Pomyk opened this issue 11 years ago • 7 comments

I have set the precision to seconds. Mongodb plugin writes timestamp in nanoseconds without respecting the precision. Influxdb then reads this and gets year 2111 (that causes some strange behavior - a new WAL after every write).

Pomyk avatar Sep 09 '15 10:09 Pomyk

You'll need to be more specific, things to include:

  1. operating system
  2. config file
  3. version number
  4. debug output

My first guess is that there is something wrong with your system's clock, I don't know how else to explain year 2111

sparrc avatar Sep 09 '15 21:09 sparrc

I still don't understand the part about year 2111, but I have found a bug in setting the precision for the plugin gathering in certain situations. I will have a fix for that soon.

sparrc avatar Sep 10 '15 03:09 sparrc

Thanks for the quick response, but that didn't fix it unfortunately. os - CentOS 7 relevant config part is:

  [agent]
    precision = "s"
  [mongodb]

influx and telegraf compiled from master output from influxd: https://gist.github.com/Pomyk/d7c707ec9432dda8cdb3

From the Line protocol docs:

"Timestamps are assumed to be in nanoseconds unless a precision value is passed in the query string."

Telegraf passes precision=s in params, but data from mongodb plugin has timestamps encoded in nanoseconds. Influxdb reads ns and multiplies by 1000000 so the timestamp overflows and the date becomes random.

Pomyk avatar Sep 11 '15 11:09 Pomyk

Okay, thanks for the info, I'll have to look into this next week. Can you please provide the debug telegraf output? and also the output of telegraf -version (if this doesn't return anything, include the commit from which you built.)

sparrc avatar Sep 11 '15 22:09 sparrc

Version v0.1.8-11-gd8482cc Debug output: https://gist.github.com/Pomyk/a2929f84882b65b28622

Pomyk avatar Sep 14 '15 13:09 Pomyk

I've reproduced this, working on a fix now

sparrc avatar Sep 14 '15 20:09 sparrc

@Pomyk wow this turned into a rabbit-hole, and actually looks like it is a bug in influxfb. I have a PR up against the InfluxDB client code (https://github.com/influxdb/influxdb/pull/4099) to fix this and will have a separate PR for telegraf sometime tomorrow.

sparrc avatar Sep 15 '15 01:09 sparrc