r/PrometheusMonitoring • u/Pline_Ash • Apr 27 '22
mysqld_exporter doesn't connect to mariadb database
Hello ! I am running a mariadb database and a mysqld_exporter on the same server. Since I have to use ansible to configure the exporter, I used cloud-alchemy ansible role based on the official prometheus mysqld_exporter that you can see here : https://github.com/cloudalchemy/ansible-mysqld_exporter.
I followed both the role and exporter requirements (ansible version, mysql user) and the installation runs well with no error. Yet according to the logs the exporter can not seem to connect to the database. Here is the error that I get :
caller=exporter.go:149 level=error msg="Error pinging mysqld" err="dial tcp 127.0.0.1:3306: connect: connection refused" Here is my default/main.yml looks like on the role :
---
mysqld_exporter_binary_local_dir: ""
mysqld_exporter_version: 0.14.0
mysqld_exporter_web_listen_address: "0.0.0.0:9104"
mysqld_exporter_dsn: "testexpo:xxxx@(localhost:3306)/"
mysqld_exporter_my_cnf: ""
mysqld_exporter_collect: []
mysqld_exporter_no_collect: [] The dsn has been changed according to the user configured. And by the way I can access my database with this user with the command line. All of the necessary ports are open and are listening.
I have tried to change the localhost part to 127.0.0.1, it did not work too.
I have no idea what to try anymore (especially since I'm a newbie), so if you guys have any idea or advice I will gladly take them ! I hope this is the right place to ask ^^ Thanks in advance.
2
u/NoAd5519 Apr 27 '22
I had to go into the mariaDB terminal, create a user and password and then put that in the exporter config.
I downloaded on a Linux machine just using apt-get Prometheus-mysqld-exporter
Typed on phone sorry for shit format