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

参考图形展示在测试中

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监控数据的主要内容,如果未能解决你的问题,请参考以下文章

MySQL: 9 为数据库部署Prometheus+Grafana监控系统

Prometheus 采集rabbitmq监控数据

Prometheus 采集rabbitmq监控数据

Prometheus 采集snmp监控数据

Prometheus 采集redis监控数据

Prometheus 采集rabbitmq监控数据