mysql + grafana监控
阅读原文时间:2023年07月17日阅读:2

1、首先需要增加授权

CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX' WITH MAX_USER_CONNECTIONS 3;

GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';

flush privileges;

2、安装mysqld_exporter

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

tar xzvf  mysqld_exporter-0.12.1.linux-amd64.tar.gz

mv mysqld_exporter-0.12.1.linux-amd64.tar.gz  mysqld_exporter

3、启动

 cat start.sh

export DATA_SOURCE_NAME='root:autodgpmysql@(localhost:3306)/'

./mysqld_exporter --web.listen-address=0.0.0.0:8089 --config.my-cnf /etc/my.cnf

监控指标:

https://github.com/prometheus/mysqld_exporter

collect.slave_status

Collect from SHOW SLAVE STATUS (Enabled by default)

collect.slave_hosts

Collect from SHOW SLAVE HOSTS

--collect.slave_status \

 --collect.slave_hosts \

4、配置prometheus.yml

  - job_name: 'mysqld'

    static_configs:

    - targets: ['localhost:8089’]

http://localhost:8089/metrics

设置报警规则

https://github.com/prometheus/mysqld_exporter/blob/master/example.rules

groups:

- name: GaleraAlerts

  rules:

  - alert: MySQLReplicationNotRunning

    expr: mysql_slave_status_slave_io_running == 0 or mysql_slave_status_slave_sql_running

      == 0

    for: 2m

    labels:

      severity: critical

    annotations:

      description: Slave replication (IO or SQL) has been down for more than 2 minutes.

      summary: Slave replication is not running

Grafana服务

http://monitor_host:3000访问Grafana网页界面(缺省的帐号/密码为admin/admin)

然后我们到Data Sources页面添加数据源

Granfana 导入Mysql 监控图表

推荐图标ID:https://grafana.com/dashboards/7362

监控展示

热门专题

vue 免费天气插件

html 漂亮的可输入下拉框

delphi 7 java unicode 编码 转中文

用Navicat创建MongoDB集合

python 查看sys path

java hive3.x依赖

PrintGCDetails 解读

PADS Logic 怎么激活菜单工具栏画图的结点进行画图

react-native 选择时间

apache 伪静态 详解

NGUI怎么封装sprite

k8创建本地存储pvc

安国Alcor AU6387

windows版gitlab

mui顶部tab栏切换时内容不切换

TSNE对词向量进行降维

阿里 abuntu 图形界面

vscode flask设置

faceswap-GAN 直播换脸

C# chart Y轴显示数据和百分比