Prometheus 采集Mysql监控数据
Posted CIAS
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Prometheus 采集Mysql监控数据相关的知识,希望对你有一定的参考价值。
Prometheus采集主机监控参考部署下载,图形生成
系统 | exporter 安装参考 | Grafana | download |
Windows | 参考 | 图形生成参考 | win_exporter |
Linux | 参考 | node_exporter | |
mysql | 参考 | Mysql_exporter | |
SQL Server | 参考 | SQL exporter | |
Redis | 参考 | Redis_exporter | |
cadvisor | 参考 | cadvisor | |
rabbitmq | 参考 | 参考 | rabbitmq |
snmp_exporter | 参考 | 图形展示在测试中 | |
zabbix | 集成参考 |
download mysqld_exporter
mysqld_exporter 一键监控安装脚本
- host=YOU_IP
- port=3306
- user=root
- password=root
- 采集端口是9104
vim /mysqld_exporter.sh
#!/bin/sh
# -*- coding: utf-8 -*-
# Date: 2022/11/18
echo "download mysqld_exporter"
sleep 2
wget -N -P /opt/ https://github.com/prometheus/mysqld_exporter/releases/download/v0.14.0/mysqld_exporter-0.14.0.linux-amd64.tar.gz
echo "download mysqld_exporter"
sleep 2
tar -xf /opt/mysqld_exporter-0.14.0.linux-amd64.tar.gz -C /opt/ && mv /opt/mysqld_exporter-0.14.0.linux-amd64 /opt/mysqld_exporter
echo "config mysqld_exporter"
sleep 2
cat << EOF > /opt/mysqld_exporter/.my.cnf
[client]
host=192.168.11.98
port=3306
user=root
password=root
EOF
echo "firewall mysqld_exporter port"
sleep 2
firewall-cmd --zone=public --add-port=9104/tcp --permanent && firewall-cmd --reload
echo "add mysqld_exporter.service"
sleep 2
cat << EOF > /usr/lib/systemd/system/mysqld_exporter.service
[Unit]
Description=mysqld_exporter
Documentation=https://prometheus.io/
Wants=network-online.target
After=network-online.target
[Service]
User=root
Group=root
Type=simple
ExecStart=/opt/mysqld_exporter/mysqld_exporter --config.my-cnf=/opt/mysqld_exporter/.my.cnf
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
echo "start mysqld_exporter.service"
sleep 2
systemctl daemon-reload && systemctl enable --now mysqld_exporter
执行安装
sh /mysqld_exporter.sh
Prometheus 数据采集配置
scrape_configs:
- job_name: 'web'
scrape_interval: 5s
static_configs:
- targets:
- localhost:9090
- job_name: 'mysql-Host-monitoring'
scrape_interval: 5s
static_configs:
- targets:
- 192.168.11.98:9104
Grafana图形展示
Import>12789>Prometheus
以上是关于Prometheus 采集Mysql监控数据的主要内容,如果未能解决你的问题,请参考以下文章