telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

MySQL input plugin binlog metrics do not work with MySQL 8.0.14+

Open rikonen opened this issue 7 years ago • 5 comments

Relevant telegraf.conf:

[[inputs.mysql]]
  servers = ["{user}:{password}@tcp(localhost:{port})/?tls=false"]
  metric_version = 2

  gather_binary_logs                        = true

System info:

Telegraf 1.8.2 (but based on visual inspection latest code has the same issue). Fedora 28. MySQL 8.0.15.

Steps to reproduce:

  1. Enable MySQL input plugin and configure it to collect binary log metrics

Expected behavior:

MySQL metrics are generated.

Actual behavior:

The MySQL metrics don't work at all.

Additional info:

Logs are repeating this:

E! Error in plugin [inputs.mysql]: sql: expected 3 destination arguments in Scan, not 2

This is most likely coming from https://github.com/influxdata/telegraf/blob/master/plugins/inputs/mysql/mysql.go#L644

if err := rows.Scan(&fileName, &fileSize); err != nil {

As of 8.0.14 SHOW BINARY LOGS returns 3 columns, as shown in https://dev.mysql.com/doc/refman/8.0/en/show-binary-logs.html. The code only expects to receive 2. Should be updated to handle variadic amount of results and pick the correct ones by name to work with old and new versions. (Same applies to all uses of SHOW ..., which are currently fragile and will break if server starts returning different set of results.)

rikonen avatar Mar 01 '19 07:03 rikonen

Good afternoon,

Is there any projection for this fix?

aimtsou avatar Jun 18 '20 11:06 aimtsou

Good morning,

Is there any projection for this fix?

whitedba avatar Oct 16 '20 01:10 whitedba

Good morning, Is there any projection for this fix?

zzcpower avatar Jan 18 '21 06:01 zzcpower

@rikonen, @aimtsou, @whitedba and @zzcpower does that problem still exist with the latest version of Telegraf?

srebhan avatar Aug 02 '23 09:08 srebhan

@srebhan I have not tested but looks like https://github.com/influxdata/telegraf/commit/14f428d2fdc22d967a3714b3288ef47f72dce330 at least tries to address this exact issue so I suspect this is fine now. Thanks for the ping, I'm closing this.

rikonen avatar Aug 13 '23 07:08 rikonen