第一步:mysql
由于mysql_exporter须要链接到mysql,因此须要建立mysql用户监控mysql数据库,并赋权限git
create user 'exporter'@'localhost' identified by '123456'; GRANT REPLICATION CLIENT, PROCESS ON *.* TO 'exporter'@'localhost'; GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost'; ALTER USER exporter@localhost IDENTIFIED WITH mysql_native_password BY '123456'; flush privileges;
第二步:github
1.下载sql_exporter,地址:https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.windows-amd64.tar.gzsql
2.mysqld_exporter-0.11.0.windows-amd64下建立.my.cnf文件,内容以下:数据库
[client] user=exporter password=123456
3.启动mysqld_exporter.exe --config.my-cnf=“xxx/mysqld_exporter-0.11.0.windows-amd64/.my.cnf”windows
4.http://localhost:9104/metrics测试是否能正常访问,显示监控数据,以下图ide
第三步:测试
配置prometheus文件,修改prometheus.yml配置以下,启动prometheus.exe,查看targets状态正常,以下图code
- job_name: 'mysql' static_configs: - targets: ['localhost:9104'] labels: instance: datav
第四步:orm
经过Grafana的**+**图标导入(Import) MySQL Overview dashboard:
1.Grafana id= 7362
2.注意选中数据源
第五步:
测试验证是否集成成功,打开dashboard,查看数据是否正常,以下图所示