grafana+prometheus监控mysql

下载mysqld_exporter插件

在被监控端mysql服务器上创建账号用于mysql exporter收集使用
1
2
3
GRANT REPLICATION CLIENT, PROCESS ON  *.*  to 'exporter'@'%' identified by '123456';
GRANT SELECT ON performance_schema.* TO 'exporter'@'%';
flush privileges;
1
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.12.1/mysqld_exporter-0.12.1.linux-amd64.tar.gz
解压
1
tar xf tar -xvf mysqld_exporter-*.tar.gz -C /app/runtime/prometheus
配置文件 .my.cnf
1
2
3
[client]
user=exporter
password=123456
在启动
1
./mysqld_exporter -config.my-cnf=".my.cnf" &
查看node_exporter是否开启
1
2
netstat -lntp
tcp6 0 0 :::9104 :::* LISTEN 4981/./mysqld_expor
修改prometheus配置文件
1
2
3
4
5
- job_name: mysql
static_configs:
- targets: ['118.25.46.244:9104']
labels:
instance: db1
重启prometheus
1
nohup ./prometheus --config.file=./prometheus.yml &

grafana配置

配置prometheus数据源
添加prometheus插件,然后配置
Mou_icon
Mou_icon
Mou_icon

下载仪表盘模板

Mou_icon

导入模板

Mou_icon
Mou_icon

坚持原创技术分享,您的支持将鼓励我继续创作!