Prometheus监控Mysql实例
配置mysql_exporter
挂载目录为/home/mysql_export
mkdir /home/mysql_export
创建链接数据库配置文件
vim my.cnf
[client]
user = export # 用户名
password = Jianren@123 # 密码
host = 172.16.0.3 # mysql地址
port = 3306 # 端口

配置Mysql数据库
创建数据库用户
CREATE USER 'exporter'@'%' IDENTIFIED BY 'ABC@123456';
对mysql_exporter用户授权
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO exporter;
启动mysql_exporter采集器
docker run -d --name mysql_export -p 7774:9104 -v /home/mysql_export/my.cnf:/etc/my.cnf prom/mysqld-exporter:v0.15.1 --config.my-cnf=/etc/my.cnf
查看是否启动成功
docker logs -f mysql_export

配置Prometheus
# mysql节点
- job_name: "mysql"
static_configs:
- targets: ["172.16.0.3:7774"]

重载prometheus配置
热更新
curl -X POST http://promethuesip/-/reload
或者重启
docker restart prometheus
配置Grafana
参考grafnan看板 https://grafana.com/grafana/dashboards/17320-1-mysqld-exporter-dashboard/
导入模版ID 17320



完成