Telegraf How to configure inputs.mysql for multiple databases on one MySQL server

telegraf
#1

Hi guys,

What I have on my InfluxDB, Telegraf and MySQL sides:
One MySQL server - 127.0.0.1:3306
5 databases:
test_db1
test_db2

test_db5

Tried:
servers = [“root:root@tcp(127.0.0.1:3306)/?tls=false”]
table_schema_databases= [“database1”,…,“database2”]

sudo service telegraf restart - OK

telegraf log shows:
tail -f /var/log/telegraf/telegraf.log
2017-12-13T23:53:10Z I! Starting Telegraf v1.4.5
2017-12-13T23:53:10Z I! Loaded outputs: influxdb
2017-12-13T23:53:10Z I! Loaded inputs: inputs.processes inputs.swap inputs.cpu inputs.disk inputs.mem inputs.system inputs.mysql inputs.diskio inputs.kernel
2017-12-13T23:53:10Z I! Tags enabled: host=mysql-example-com
2017-12-13T23:53:10Z I! Agent Config: Interval:10s, Quiet:false, Hostname:“host=mysql-example-com
”, Flush Interval:10s
2017-12-14T00:09:05Z I! Starting Telegraf v1.4.5
2017-12-14T00:09:05Z I! Loaded outputs: influxdb
2017-12-14T00:09:05Z I! Loaded inputs: inputs.system inputs.mysql inputs.disk inputs.kernel inputs.mem inputs.processes inputs.swap inputs.cpu inputs.diskio
2017-12-14T00:09:05Z I! Tags enabled: host=mysql-example-com
2017-12-14T00:09:05Z I! Agent Config: Interval:10s, Quiet:false, Hostname:“host=mysql-example-com
”, Flush Interval:10s

So far so good.

But InfluxDB console doesn’t show any database1 or database2 tag keys for measurement ‘mysql’.
Whats wrong with my configuration?

#2

Make sure you have gather_table_schema enabled as well:

[[inputs.mysql]]
  servers = ["dbn@tcp(debian-stretch:3306)/"]
  table_schema_databases = []
  gather_table_schema = true

This should produce several measurements starting with info_schema:

> info_schema_table_rows,server=debian-stretch:3306,schema=foo,table=howdy,host=loaner value=0 1513237216000000000
> info_schema_table_size_data_length,server=debian-stretch:3306,component=data_length,schema=foo,table=howdy,host=loaner value=16384 1513237216000000000
> info_schema_table_size_index_length,schema=foo,table=howdy,host=loaner,server=debian-stretch:3306,component=index_length value=0 1513237216000000000
> info_schema_table_size_data_free,server=debian-stretch:3306,schema=foo,table=howdy,host=loaner,component=data_free value=0 1513237216000000000
> info_schema_table_version,server=debian-stretch:3306,schema=foo,table=howdy,host=loaner,type=BASE\ TABLE,engine=InnoDB,row_format=Compact value=10 1513237216000000000
#3

Hi Daniel,

Thanks a lot for feedback. But again all mysql measurements including table_schema_databases are collected in total, aggregated manner, w/o database names segregation. Also, I provided database name in server definition - servers = [“root:root@tcp(127.0.0.1:3306)/database1?tls=false”]. But Telegraf collects aggregated data again.

Will appreciated for further advise.