xmh
xmh

Reputation: 135

How to set the dsn of [inputs.sql] while using telegraf to connect MySQL?

I use docker-compose.yml to deploy MySQL, InfluxDB and Telegraf. I want to write the data of a MySQL database to an InfluxDB database through Telegraf. How to set the dsn of [inputs.sql] plugin while using telegraf to connect MySQL? Here are my settings: enter image description here enter image description here It is said the dsn should be set as followed:

username:password@protocol(address)/dbname?param=value

My config turn out to be wrong:

E! [telegraf] Error running agent: starting input inputs.sql: connecting to database failed: dial tcp 192.168.48.5:3306: connect: connection refused

Can you tell me how to fix it? Thank you very much.

Upvotes: 0

Views: 800

Answers (1)

Munin
Munin

Reputation: 1649

Looks like there is connection issue there. Could you first test your MySQL connection from where the Telegraf agent is deployed?

  1. Open a terminal from where the Telegraf agent is deployed
  2. From inside the command prompt, type the command telnet 3306. In your case, that would be:

192.168.48.5:3306

  1. Hit enter to activate the command. If the MySQL service is running, you will receive a response from the server. If not, please make sure the MySQL is up and running and the firewall is clear.

Upvotes: 2

Related Questions