当前位置:Gxlcms > 数据库问题 > Grafana+Prometheus系统监控之MySql

Grafana+Prometheus系统监控之MySql

时间:2021-07-01 10:21:17 帮助过:22人阅读

REPLICATION CLIENT, PROCESS ON *.* TO ‘exporter‘@‘localhost‘ identified by ‘123456‘; GRANT SELECT ON performance_schema.* TO ‘exporter‘@‘localhost‘; flush privileges;

创建.my.cnf文件 vi .my.cnf:

[client]
user=exporter
password=123456

运行mysqld_exporter:

./mysqld_exporter -config.my-cnf=".my.cnf" &

Prometheus配置

修改prometheus.yml加入MySql节点:

global:
  scrape_interval:     15s
  evaluation_interval: 15s

scrape_configs:

  - job_name: prometheus
    static_configs:
      - targets: [‘localhost:9090‘]
        labels:
          instance: prometheus

  - job_name: linux1
    static_configs:
      - targets: [‘192.168.1.120:9100‘]
        labels:
          instance: sys1

  - job_name: linux2
    static_configs:
      - targets: [‘192.168.1.130:9100‘]
        labels:
          instance: sys2

  - job_name: redis1
    static_configs:
      - targets: [‘192.168.1.120:9121‘]
        labels:
          instance: redis1

  - job_name: mysql
    static_configs:
      - targets: [‘192.168.1.120:9104‘]
        labels:
          instance: db1

保存以后重启Prometheus,查看targets:

技术分享图片

最后登录grafana查看MySql监控信息:

技术分享图片

参考文档:
https://github.com/prometheus/mysqld_exporter

Grafana+Prometheus系统监控之MySql

标签:oar   src   man   安装配置   span   文档   oca   es2017   mysqld   

人气教程排行