prometheus监控mysql8.x以及主从监控告警

mysql8.x主从部署请看下面文档 docker和yum安装的都有

Docker部署mysql8.x版本互为主从_争取不加班!的博客-CSDN博客

Mysql8.x版本主从加读写分离(一) mysql8.x主从_myswl8双主一从读写分离_争取不加班!的博客-CSDN博客

安装部署mysqld_exporter

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.13.0/mysqld_exporter-0.13.0.linux-amd64.tar.gz

tar -xvzf mysqld_exporter-0.13.0.linux-amd64.tar.gz -C /usr/local/

cd /usr/local/mysqld_exporter-0.13.0.linux-amd64/

vim ./my.cnf 编辑一个文件 启动exporter的用户和密码

client

host=localhost 监控其他主机换成ip即可

user=root 注意用户权限 创建一个有权限的用户

port=3306

password=Zxcvbnm@2022

nohup ./mysqld_exporter --config.my-cnf=./my.cnf --web.listen-address=":9104" 指定端口

& 运行

--web.listen-address=":9104" 运行多个的话指定其他端口即可

ps -ef |grep mysqld_exporter

kill -9 114835 关闭

然后编辑prometheus配置配件

vim prometheus.yml

systemctl restart prometheus 重启

启动mysql_exporter

vim nohup 看一下启动日志

192.168.11.193:9104/metrics 启动后查看 有数据则启动成功

以上配置好以后在Grafana中配置mysql的监控模板

在Grafana官网中下载mysql的监控模板 Dashboards | Grafana Labs

下载好以后来到GrafanaWEB页面

配置完成!!!

Grafana mysql8.x监控模板id 14057

然后编写mysql的告警规则

#mysql服务挂掉时触发告警

  • alert: Mysql状态

expr: mysql_up == 0

for: 10s

labels:

severity: warning

annotations:

summary: ' {{ $labels.instance }} Mysql服务 '

description: " {{ $labels.instance }} Mysql服务不可用 请检查"

#mysql主从IO线程停止时触发告警

  • alert: Mysql主从IO线程检测

expr: mysql_slave_status_slave_io_running == 0

for: 5s

labels:

severity: error

annotations:

summary: " {{ $labels.instance }} Mysql从节点IO线程"

description: "Mysql主从IO线程故障,请检测"

#mysql主从sql线程停止时触发告警

  • alert: Mysql主从sql线程检测

expr: mysql_slave_status_slave_sql_running == 0

for: 5s

labels:

severity: error

annotations:

summary: "{{ $labels.instance }} Mysql从节点sql线程"

description: "Mysql主从sql线程故障,请检测"

systemctl restart alertmanager prometheus 重启 alertmanager和 prometheus

stop slave sql_thread; 停掉 从库的sql线程看下

收到告警配置完成

相关推荐
lbb 小魔仙4 天前
OpenClaw + cpolar 实战:远程 NAS、分享小游戏、RDP,再配置公网 AI 入口
数据库·人工智能·redis·oracle·prometheus
zhoupenghui1685 天前
Golang pprof 工具详解:监控、压测与调优实战指南
prometheus·pprof
ggaofeng6 天前
prometheus时序数据库
prometheus
A心有千千结10 天前
Nginx网关可观测建设:打通流量入口,加速线上故障诊断
nginx·prometheus·devops
天天喝旺仔10 天前
Prometheus + Grafana 监控告警体系搭建实战:从 Exporter 指标采集、PromQL 查询到 Alertmanager 告警落地
容器·kubernetes·grafana·prometheus·时序数据库
川石课堂软件测试14 天前
涨薪技术|Prometheus之HTTP API中使用PromQL
网络协议·测试工具·jmeter·http·单元测试·postman·prometheus
IT界的老黄牛16 天前
Prometheus TSDB 拆不出来、也存不了一年:4 条外部存储出路 + 容量测算
prometheus·时序数据库·监控·thanos·victoriametrics·remote_write
Ningcode_cloud16 天前
Kubernetes 弹性伸缩实验手册:从集群搭建到 HPA / VPA 自动扩缩容
云原生·k8s·prometheus
2601_9620973617 天前
可观测性实战:Prometheus+Grafana+OTel构建监控
grafana·prometheus·微服务架构·可观测性·opentelemetry
IT界的老黄牛17 天前
Jenkins 监控一条龙:接入、看板 9964、11 条告警规则直接抄走
jenkins·grafana·prometheus·监控·ci-cd·告警规则