prometheus mysqld_exporter 监控 mysql
来源:原创
时间:2022-01-13
作者:脚本小站
分类:DB
下载mysqld_exporter:
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz
配置文件:
vim .my.cnf [client] host=127.0.0.1 user=root password=root
创建systemd:
vim /usr/lib/systemd/system/mysqld_exporter.service [Unit] Description=node_exporter Documentation=https://prometheus.io/ After=network.target [Service] Type=simple ExecStart=/usr/local/mysqld_exporter/mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/.my.cnf Restart=on-failure [Install] WantedBy=multi-user.target
启动服务:
systemctl daemon-reload && systemctl enable mysqld_exporter.service && systemctl start mysqld_exporter.service && systemctl status mysqld_exporter.service
配置prometheus.yml:
- job_name: 'mysqld' file_sd_configs: - files: ['/usr/local/prometheus/mysqld.yml'] refresh_interval: 1m
创建服务发现文件mysqld.yml:
- targets: ['192.168.199.218:9104'] labels: name: mysql
重载配置:
curl -XPOST localhost:9090/-/reload
grafana:
https://grafana.com/grafana/dashboards/7362