mysqld_exporter用来抓取mysql的相关信息:
tar zxfv mysqld_exporter-0.10.0.linux-amd64.tar.gz -C /home
mv /home/mysqld_exporter-0.10.0.linux-amd64 /home/mysqld_exporter
mysql -u root -p'xxxx'
grant replication client,process on . to 'prom'@'localhost' identified by 'xxxx';
grant select on performance_schma.* to 'prom'@'localhost';
exit
vi /home/mysqld_exporter/.my.cnf
[client]
user=prom
password=xxxx
:wq
/home/mysqld_exporter/mysqld_exporter -config.my-cnf=/home/mysqld_exporter/.my.cnf
netstat -nplt | grep 9104
prometheus端:
vi /home/prometheus/prometheus.yml
targets: ['xxxx:9104']
:wq
grafana面板:
显示mysql是否up(up为1):
mysql_up{instance=~"db1:9104"}
显示mysql的uptime时间:
mysql_global_status_uptime{instance=~"db1:9104"}
显示mysql的连接数:
mysql_global_status_threads_connected{instance=~"db1:9104"}
显示正在运行的进程数:
mysql_global_status_threads_running{instance=~"db1:9104"}
显示等待写入的个数:
mysql_global_status_innodb_data_pending_writes{instance=~"imanage-db1:9104"}