ELK MetricBeat - Monitor remote mysqlDB

I have installed ELK stack (With metricbeat) on ServerA and want to monitor mysql on ServerB. I added db host details on ServerA mysql.yml metribeat module file (/etc/metricbeat/modules.d/mysql.yml)

    - module: mysql
  metricsets:
    - status
    - performance
  period: 10s

  hosts: ["tcp(ServerB:3306)/"]

  username: mysql

  password:password

After I start the metricbeat instead of connecting to ServerB it tries to connect to localhost(ServerA) mysql.

below is the error

Error fetching data for metricset mysql.status: Error 1045: Access denied for user 'mysql'@'ServerA...sing password: YES)

Can someone help me with this?

This is not a issue with metricbeat, it is correctly trying to connect to ServerB, the error you are seeing is the response from MySQL saying that he user mysql was denied, you will probably need to check your grants.

This is a MySQL issue, so you will need to grant access for the mysql user to connect from the serverA. I'ts been a long time since I've used MySQL, but if I remember correctly you will need something like this:

GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'serverA' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

Hi Leo,
Thanks for looking into this?
User has full access to mysql. If you look at the error its connecting to ServerA (Access denied for user 'mysql'@'ServerA) it should be mysql@ServerB?

No, as I said, the problem is in the permission for the user mysql, it is not in metricbeat.

The message Access denied for user 'mysql'@'ServerA' usingsing password: YES is sent by your MySQL server.

It says that the user mysql does not have grants to access the database when connecting from ServerA. The first part is the username and the second part is the name of the host from where the connection is comming, in your case it is ServerA, where your metricbeat is running.

When you create a user in mysql you need to specify the hosts from where this user will be allowed to connect to the server. The user can have full access when connecting to mysql from ServerB, but could be denied from any other host.

You need to grant access from other hosts. Take a look at the mysql documentation about creating users, the host name is parte of the identification of the user.

Hi Leo,
Thank you for the detail explanation.
It was a access issue and now I'm able to connect.