windows上prometheus+Grafana监控mysql8.0状态

你说的曾经没有我的故事 提交于 2019-11-28 21:57:45

第一步:

因为mysql_exporter需要连接到mysql,所以需要创建mysql用户监控mysql数据库,并赋权限


 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;

 

第二步:

1.下载sql_exporter,地址:https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.windows-amd64.tar.gz

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”

4.http://localhost:9104/metrics测试是否能正常访问,显示监控数据,如下图

 

第三步:

配置prometheus文件,修改prometheus.yml配置如下,启动prometheus.exe,查看targets状态正常,如下图

  - job_name: 'mysql'
    static_configs:
    - targets: ['localhost:9104']
      labels:
        instance: datav 

 

第四步:

通过Grafana的**+**图标导入(Import) MySQL Overview dashboard:

1.Grafana id= 7362

2.注意选中数据源

 

第五步:

测试验证是否集成成功,打开dashboard,查看数据是否正常,如下图所示

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!