基于Prometheus构建MySQL可视化监控平台(已用于线上环境)

作者介绍

罗辉,原荔枝FM运维工程师。近十年互联网运维经验,经历过从传统运维到自动化运维的转变。擅长Zabbix、Ansible、Openstack、Python、Docker、Kubernetes。

概述

对于MySQL的监控平台,相信大家实现起来有很多了:基于天兔的监控,z c M还有基于zabbix相关的二次开发。相信很多同行都应该已经开始玩起来了。

我这边的选型是prometheus + granafa的实现方式。简而言之就是我现在的生产环境使用的是proX 6 L c S = emetheus,还有就是granafa满足的我的日常工作需要。

1、首先看下我们的: ? G | j 8 监控效果、mysql主从

基于Prometheus构建MySQL可视化监控平台(已用于线上环境)

2、mysql状态

基于Prometheus构建MySQL可视化监控平台(已用于线上环境)

基于Prometheus构建MySQL可视化监控平台(已用于线上环境)

3、缓冲池状态

基于Prometheus构建MySQL可视化监控平台(已用于线上环境)

exporter相关部署

1、安装exportz / ! r ?er

[root@controller2 opt]# https://github.com/prometheus/mysq { 3 . Hld_exporter/releases/download/U | G p Iv0.10.0/mysqld_, L C Nexporta [ l 8 * ) W s :er-U 4 5 L : L0.10.0.linux-amd64.tar.gz

[roM c Lot@controller2 optU _ F 5]# tar -xf mysqld_o W q = D u *exporter-0.10.0.linux-amd64.tar.gz 

2、添加mysql 账户

GRANT SELECT, PROCESS, So ! Y Q = DUPER, REPLICATION CLIENT, RELOAD ON *.* TO \'exporter\'@\'%\' IDENTIFIED BY \'localhost\';

flush privileges;

3、编辑配置文件

[roW 4 m O x 0ot@controller2 mysqld_exporter-0.10.0.linux-amd64l O M J X  !]# cat /opt/mysqld_exporter-0.10.0.linux-_ ^ y ` C 9 ;amd64/.my) b ~ [ . 8 @ q D.cnf 

[client]

user=exporter

passwoN B J 1 W . Drd=123456

4、设置配置文件

[root@controller2 mysqld_exporter-0.10.0.linux-amd64]# cat /etc/sb | . g  . H Hystemd/system/mysql_exporter.sc G ! Lervice 

[Unit]

Description=mysql Monitoring System

Documentation=mysql Monitoring System

[Service]

ExecStart=/opt/mysqld_exporter-0.10.0.linux-amd64/mysqld_exP y G ] ]porter \\

        &nb? q 5 M +sp;-collect.info_schema.processlist \\

         -collect.info_schemf 2 u u u ;a.innodb_tablespaceD Z ~ 5s \\

  &nbz Zsp;      -collect.info_scX c , 7hema.innodb_metrics  \\

         -collect.perf_schema.tableiowaits \\

         -collect.perf_schema.indexiowaits \\

         -collect.perf_schema.tablelocks \\

  &nT , h H [bsp;  ( J o C U j    -collect.engine_innodb_staC F ` V h C F ntus \\

       J W y z M n 6 2 R;  -collect.p( + 0 0erf_schema.fO p Bile( n f . r `_events \\

         -P a [ N A W B 4 Fcollect.info_schema.processlist \\

&n$ o &bsp;        -collect.binlog_Q ^ 7 ! J A !size \\

         -collect.info_schema.clientstats \\

    &n^ j =bsp;    -collect.perf_schema.eventswaits \\

         -config.my-cnf=/opt/mysqld_exporter-0.10.0.+ T G 8 e l s Ilinux-amd64/# a M c L.my.cnf

[Inx y Jstall]

WantedBy=multi-user.target

5、添加配置到prometheus servU d v J W ier

  - job_name: \'mysql\'

    stat { s 0 ltic_configs:

     - targets: [\'192.168.1.11:9104\',\'192? $ ) [ #.168.1.12:9104\']

6、测试+ P L u { u L看有没有返回数值

http://192.168.1.12:9r j Z104/metric^ f ) q m $ q d 5s

正常我们通过mysql_up可以查询倒. { ( - 8 - ~mysql监控是否已经生效,是Y ] 0否起起来:

#HELP mysql_up Whether th^ + ye MySQL server is up.

#TYPE mysql_up gauge

m? * % s # 6ysql_u] s @ 4 Wp 1

监控相关指标

在做任何一个东西监控的时C S Q候,我们要时刻明白我们要监控的是什么,指标是啥才能更好H V I s b的去监控我们的服务,在mysql里面我们通常可以通过一下指标去衡量mysql的运行情况:mysql主从运% } % = F W e% h ? A情况、查询吞吐量、慢查询情况、连接数情况、缓冲池使用情况以及查询执行性能等。

主从复制运行指标

1、f x ; 主从复制线程监控

大部分情况下,很多企业使用的都是主从复制的环境,监控两个线程是非常a G | 4 u d重要的,在mysql里面我们通常是通过命令:

MariaDB [(none)]> show slave status\\G;

**= J ( Q U************************* 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  MasterY N 1 K p_Host: 172.16.1.1

 : c e U;             &nt + o | Y } c Y Wbsp; &nbsm { *p; Master_User: repl

&nby j V s p % _ (sp;                 Master_Port: 3306

          &c ~ mnbsp;     Connect_Retry: 60

       L % ;     &@ J T F w G unbsp; Master_Log_File: mysql-bin.000045

          Read_Master_Log_Pos: 72904854 4 ` + %

           ^ R Q    Relay_Log_File: mariadb-relay-bin.000127

                Relay_Log_Pos: 72905142

        Relay_Master_Log_File: mw 6 : g Iysql-bin.000045

             Slave_IO_Running: Yes

         f [ O i o j V Q -   Slave_SQL_Running: Yes

#Slave_IO_Running、Slave_SQL_Running两个线程正常那么说明我们的复制集群是健康状态H ) c O的。

MQ % @ K X -ySQLD Exporter中返回的样本数据中通过mysql_slave_status_slave_sql_running来获取主从集群的j % -健康状况。

# HEL% S LP mysql_slave_statusc 6 B  [ n_slave_5 K S ? S 9 fsql_running Generic metY $ N Xric from SHOW SLAVE STATUS.

# TYPE mysql_slave_status_slave_sql_running untyped

mysql_slave_status_slave_sql_r= 8 I 9uA Q + ; P #nning{channel_name=\"\",connection_name=\"\",maN D W R zster_host=\"172.16.1.1\",master_uuid=\"\"}Y 6 $ a 1

2、主从复制落后时间

在使用show slave status 里面还有一个关键的参数Seconds_Behind_Master。Seconds_Behind_Master表示slave上SQL thread与IOG [ n J X W : q @ thread之间的延迟,我们都知道H a V g o ? V `在MySQL的V | { F Z复制环境中,slave先从master上将binlx h 4oK t tg拉取到本地(通过IO thread),然后通过SQL thry 8 O S C : @ a he( % ^ x M { 7 5 +aK * 1d将binlog重放,而Seconds_Behind_Master表示本地relayV h B T h log中未被执行完的那部分的差值。

所以如果R x Eslave拉取到本地的relaylog(实际上就是bt k U h 2 x s j ginlog,只是在slave上习惯称呼relay, | h &log而已)都执行完,此时通过show slave status看到的会是0。

Seconds_Behind_Master: 0

My4 P b B + SSQLD Exporter中返回的样本数据中通过mysql_slK : O i R {ave_status_seconds_behind_master 来获取相关状态。

# HELP mysql_slave_status_] | ] O ) 4 &seconds_behind_master GeneriC 0 g $ 3 } +c metric from SHOW SLAVE STATUS.

# TYPE mysql_slave_status_seco_ | P ? D } L vnds_behind_master untyped

mysql_slave_status_sK ? v Q / e b K Zeconds_behind| / O s , ( D B c_masz ) | f ; qter{channel_name=. f 1 / 8\"\",connection_name=\"\",master_host=\"172.16.1.1\",master_uuid=\"\"} 0

查询吞吐量:

说到吞吐量,那么我们如何从那方面来衡量呢1 i -

通常来说我们可以根据mysql 的插入、查询、删除、更f G S u r Z新等操作来衡量。

为了获取吞吐量,F R uMySQL 有一个名为 Questions 的内部计数器(根据 MySQL 用语,这是一个服务器& . 6状态变量),客户端每发送一个查询语句,其值就会加一。由 Quc 6 F Eestions 指标带来的以客_ D Y w /户端为中心的视角常常比相关的Queries 计数器更容易解释。作为存储程序的一部分,后者也会n % Q计算已执行语句的数量,以及诸如PREPARE 和 D} L Q v k H WEALLOCATE PREPARE 指令运行的次数,作为服务器端预处理语句的一部分。可以通过命令来查询:

MariaDB [p U 5 T [ ; K(none)]> SHOW GLOBA e + l C F a w {AL STATUS LIKE \"Questions\";

+---------------+-------+

| Variabl: i o Z ` f 2 6 de_name | Value |

+---------------+-------+

| Questions     | 15071 |

+---------------+-------+

MySQLD Exporter中返回的o 5 r L ^ M样本数据中通过mysql_global_status_questions反映当前Questions计数器的大小:

# HELP mysql_global_status_questions Generic metric from SHOW GLOBAL STATUS.

# TYPE mysql_global_s@ e d Y O I |tatus_questions un| = 9typed

mysql_global_statf ! I V f 3us_questions 13253

当然由于prometheus 具有非常丰富的查询语言,我们可以通过这个累加的计数器来查询某一短时间内的查询增长率情况,可以做相关的阈值告警Z R k : ? _处理、例如一下查询2分钟时间内的查询情况:

rate(mysqlS E 6 ] @ & u ( s_global_status_questions[2m])_ y 9 h

当然上面是总量,我们可以分别从监控读、写指令的分解情况,从而更好地理解数据库的工作负载、找到可能的瓶颈。通常,通常,读取查询会由 Com_select 指标抓取,而写入查询则可能增加三个状态变量中某一个的值,这取决于具体的指令:

WrT Z = ! x l h Xites = Ca b Som_insert + Com_update + Com_delete

下面我们通过命c ? T令获取插入的情况:

MariaDB [(nj = U o W { , [ Qone)]> SHOW GLOBAL STATUS LIKE \"Com_insert\";

+---------------+-------+s s A /

| Variable_nam9 4 R D te | Value |

+---------------+-------+

| Com_insert    | 1V @ U n I x g0578 |

+---------------+-------+

从MySQLD Exporte* K J x Y J A % Kr的/metrics返回的监控样本中@ D :,可以通过global_status_commands_total获取当前实例各类指令执行的次数:

# HELP mysql_global_status_commands_total Total number of executed MySQL commands.

# TYPD E W ~ WE mysql_global_statush u ; [ . Q =_commanw d E : ~ I I 6 rds_toj Y d Ktal counter

mysqc ) 5 W z N N )l_global_status_commands_total{commh G ) q -and=\"cF + m I Ureate_trigger\"} 0

mysql_glt C i W 7 L Robal_status_commands_totj o $ l B @ m . Sal{command=\"create_udf\"} 0

mysql_global_statusD - p o V @_commands_total{command=\"create_user\"} 1

mysql_global_status_commands_total{command=\"create_view\"} 0

mysql_; ) #global_status_commands_total{command=\y w j y 8 x c"dealloc_sql\f d g z T t"} 0

mysql_global_status_commands_total{command=\"delY ~ ` p rete\"} 3369

mysql_global_status_commands_total{command=\"delete_multi8 S a d ! S = b\"} 0

慢查询性能

查询性能方面,慢查询% L z D t也是查询告警的一个重要的指标。MySQL还提供了一个Slow_queries的计数器,当查询的执行时间超过long_query_time的值C A : h M h X 3后,计数器就会+1,其默认值为10秒,可以通过以下指令在MySQ9 C G ` ` IL中查询当前lon4 9 =g_query_tm y $ : r ) n jime的设置:

MariaDB [(none)]> SHOW VARIABLES LIKE \'long_query_time\';

+----------------] H a a A-+-----------+

| Variable_name   | Value     |

+-----------------+-----------+

| long_query_time | 10.000000 |

+----& R K j-------------+-----------+

1 row in set (0.00 secW Q Y ; r)

#当然我们也可以修改时间

Mari2 $ J # 5 } l +aDB [(none)]> SET GLOBAL long_query_time = 5;

Query OK, 0 rows affected (0.00 sec)

然后我们而已通过sql语言查询MySQL实例中2 ~ J ( ^ # 4Slow_queries的~ } x v o ^数量:

MariN - p 4aDB [(none)]> SHOW GLOBAL STATUS LIKE \"Slow_queries\";

+---------------+-------+

| Variable_name | Value |

+----A D b z A 0 v y-----------+-------+

| Slow_queries  | 0     |

+---------------+-------+

1 row in set (0.00 sec)

MySQLD Exportt $ Z f B . c x Aer返回的样5 9 $ e ^ P本数据中,通过mysql_global_status_D I k ,slow_qe R ^ Bueries指标展示当前的Slow_queries的值:

# HELP mysql_globaF M 3 P wl_status_slow_queries Generic metric from SHOW GLOBAL STATUS.

# TYPE mysql_global_status_slow_queries untyph J a F W + U N ted

mysql_global_status_sl[ S h 2 F 0ow_queries 0

同样的,更具根据PrZ Z _ L dometheus 慢查询语句我们也可以查询倒他某段时间内的增长率:

rate(mysql_global_status_slow_queries[5m])

连接数监控

监控客户端连接情: 2 k ( i ` H @ ?况相当重要,r N M因为一旦可用连接耗尽,新- c L E % % Q ) Q的客户端连接就会遭到拒绝。MySQL 默认的连接数限制为 151。

MariaDB [(none)]>; { q G _ 1; SHOW VARIABLES LIKE \'max_U  F Nconnections\';

+--------J ! 6 p #---------+-------+

|& V Z A Variable_name   | Value |

+-----------------+-------+

| max_connections | 151   |

+---------s S F t q ^ ;--------+-------+

当然我们可以修改配置文件的形式来增加这个数值。与之对应的就是当前连接数量,当我们当前连接出来超过系统设置的最大值之后常会出现我们看到的TooE * ( v 5 mr O Z A G s &any connectionsM p x @(连接数过多),下面我查找一下当前连接数:

MariaDB [(none)]> SHOW GLOBAL STATUS LIKE \"Threads_connected\";

+-------------------+-------+

| Variable_name &n& j e ? 6 j X 6bsp;   | Value |

+-------------------+-------+

| Threads_connected | 41     |

+---------------i N A ? C f ] [ Q---- ( I l+-------

当然mysql 还提供Threads_running 这个指标,帮助你分隔在任意时间正在积极处理查询的线程与那些虽然可用但是闲置的连接。

MariaDB [(none)]> SHOW GLOBAL STATUS LIKE \"Threads_running\";y v m F G % ^ / ~

+-----------------+-------+

| Variable_name   | Value |A 5 @ b 2 m D | ^

+-----------------+-------+

| Threads_running | 10     |

+-----------------+-------+

如果服务器真的达到 max_: q a P jconnections 限制,它就会开始拒绝新的连接。在这种情况下,Connection_erra ` & D Mors_max_connections 指标就会开始增加,同时,追踪所有失败连接尝试的Aborted_connects 指标也会开始增加。

MySQLD Ex8 - V N C ; /porter返回的样本数据中:

# HELP mysql_global_variables_max_connecti4 y +oj : [ & E  )ns Generic gauge metric from SHOW GLOBAL VARIABLES.

# TYPE mysql_global_variables_max_conne, [ g Gctions gauge

mysql_global_variables_max_connections 151  

#表示最大连接数

# HELP mysql_gK v y K ^ G mlobal_status_threads_connected Generic metric = ? u l from SHOW GLw | ; VOBAL STATUS.

# TYPE mysql_global_status_threads_connected untyped

mysql_global_status_threads_connected 41

#表示当前的连接数

# HELP mysqlu r Q f_global_status_threads_runningY s C ) Genericf : # R @ metric from SHOW GLOBAL STATUS.

# TYPEi R # E mysql_global_status_threads_running untypT j y x n % ` n med

mysql_global_status_thru d Reads_running 1

#表示当H l 0 % 6 } u R前活跃的连接数

# HELP mysql_global_status_aborted_connects Generic metri$ 8  . ) A ~ Qc from SHOW GLOBAL STATUS.

# TYPE mysql_global_status_aborted_connects untyped

mysql_globaQ U ` % 7 & 3l_status_aborted_connects 314 H , B ) c 8 |

#累计所有的连接数

# HA 6 / ? 5 YELP mysql_global_status_connectio& : / ^ f n v 9 ,n_errors_total Total number of8 * T 5 W 5 MySQL connection errors.

# TYPE mysql_global_status_M & . 4 V k 1 ]connection_errors_total counter

mysql_global_status_connection_errors_total{err$ # : L ! F 1or=\"interM - X 1 * N s i snal\"} 0

#服务器内部引起的错误、如内存硬盘等

mysql_global_status_connection_errors_t Z E e m # 7 /total{error=\"max_connections\"} 0

#超出连接处引起的错误

当然根据prom表达式,E z ; L 8 -我们可以查询当前剩余可用的连接数:

mysql_global_variables_max_conne8  ~ a 4 $ t 3ctions -mysql_global_status_threads_connected

查询mysq拒绝连接数:

mysql_global_status_aborted_connects

缓冲池情况

MySQL# y ! U l f 8 7 默认的存储引擎 InnoDB 使用了一片称为缓冲池的内存区域,用于缓存数据表与索引^ = 6 p { k的数据。缓冲池指标属于资源指标,而非工作指标,前者更多地用于调查(而非检测)性能问题。如果数据库性能开始下滑,而G 6 b 3 O _ %磁盘 I/O 在不断攀升,扩大缓冲池往往能带来性能回升。

默认设置下,缓冲池的大小通常相对较小,为 128MiB。不过,MySQL 建议可将其扩大至专用数据库服务器物 f % O O u B理内存的 80% 大小。我们可以查看一下:

MariaDB [(none)]> show global variables like \'innodb_buffer_pool_sio k g 7 7 Qze\';

+-------------------------+-----------+

| Va| Q * ~ sriable_name           | Value8 ~ : z | q M v   &nH Z { }bsp; |

+-------------------------+---------y j % ! 4 %--+

| innodb_buffer_pool_size | 134217728 |

+----------------c Q a B T---------+-----------+

MySQLD Exporter返回的样本数据中,使用mys Y 7ql_global_variables_innodb_buffer_pool_size来表示。

# HELP mysql_global_variables_innodb_buffer_pool_s: J s % %ize Generic gauge metric from SHOW GLOBAL VARIABLES.

# TYPE mysql_globa$ C ~ }l_variables_inn. w K n rodb_buffer_pool_size gauge

mysql_global_variables_innodb_buffer_pool_size 1.34217728e+08

Inn+ z U r ? 8 % Lodb_buffer_pool_read_requests记录了正常从缓冲池读取数据的请求数量。可以通过以下指令查看

MariaDB [(none)]> SHOW GLOBAL STATUS LIKE \"Innodb_buffer_pool_read_requests\";

+----------------------------------+-------------+

| Variable_& 9 _ [name &nbs2 Y `p;        J @ q f : Q z a `          | Va_ ] P * Q Y w [lue       |

+----------------------------------+-------------+

| Innodb_buffer_pool_read_request1 X } Cs | 38465 |

+----------------------------------+-------------+

MySQLD Exporter返回的样本数据中,` W { = x k P使用mysql_global_status_innodb_buffer_pool_read_requests来表示。

# HELP mysql_global_status_innodb_buffer_pool_read_requests Generic metric from SHOW GLOBAL STATUS9 S x D w.

# TYPE mysql_global_status_innodb_buffer_@ B = H ^ = ,pool_read_requests untyped

mysql_global_status_innodb_buffer_pool_read_requests 2.7711547^ G ! `168e+10

当缓冲池无法满足时,MySQL只能从磁盘中读取E & U ; m v n数据。Innodb_buffe [ % d 4 , Cr_pool_reads即记录了从磁盘读取数据的请求数量。通常来说从内存中读取数据的速度要比{ # G E X h w K从磁盘中读取快很多,因此,如果Innodb_buffer_pool_reads的值开始增加,可能意味着数据库的性能有问题。可以通过以下只能查看Innodb_buffer_pool_reads的数量:

MariaDB [` 6 R M q p g K ,(none)]&X u t R h m O / ~gt; SHOWY R . ; C | 2 GLOBAL STATUS LIKE [ ? e `\"Innodb_buffer_pool_rR G - o ( ?  ; *eads\";

+--------------------------+-------# L W+

| Variable_name            | Value |

+--------------------P B K m i H u-----n O X U S q 7-+-------+

| Innodb_buffer_pool_reads | 138  |

+-----------------------# K ! # $ * J z 9---+-------+

1 row in set (0.00 sec)

MySQLD Exporter返回的样本数据中,使用mysql_global_status_innodb_buffer_pool_read_requeu U , y usts来表示。

# H L % = CELP mysql_gl_ X a } Z e h b obal_status_inn $ e 9 5 ~odb_buffer_po1 { ! X / + / t lol_reads Generic metric from SHOW GLOBAL STATUS.

# TYI ? G T $ X ` MPE mysql_global_status_i3 R * 8 = *nnodb_buffer_pool_reads untypeS c ^ &d

mysql_global_status_innodb_buffer_pool_reads 138

通过以上监控指标,以及Q 9 M L B实际监控的场景,我们可以利用PromQL快速建立多个监控项。可以查看两分钟内读取磁盘的增长率的增长率:

rate(mysql_global_statn p ` p ] * c Gus_innodb_buffer_pool_reads[2m])

简单的告警规则

除了相关模板h p [ + W s之外,没有告警规则那么我们的监控就是不完美的,下面列一下我们的监控告警规则。

groups:

- name: MySQL-rules

  rules:

  - alert: MySQL S% . Ztatus 

    expr: up == 0

   N N 0 J v $; for: 5s 

    labd = F wels:

      s! v + teverity: warning

    annotations:

      summary: \"{{$labels.instance}}: MySQL has stop !!!\"

      description: \"检测MySQL数据库运行状态\"

  - alert: MySQL Slave IO Thread Status

&n& Z _bsp; & 8 6nbsp; ex T %pr: mysql_Z ` e & [ m k 3 Wslavep E [ Z p W ?_status_slave_io_running == 0

    for: 5s 

    labels:

      severity: warning: l O q ~ H

   , y G =; annotations:&n 6 nbsp;

   i r ( k;   summary: \"{{$labD e O ; 7els5 ; n d X F.instance}}: MySQL Slave IO Thread has stop !!!\"

      description: \"检测MySQL主从IO线程运行状7 $ [ F w A .态\"

  - alert: MySQL Slave SQL Thread Status 

    expr: mysql_slave_status_slave_sql_running == 0

    for: 5s 

    labels:

      severity: warning

   ( A annotations: 

      summary: \"{{$1 @ )la^ u + 2bels.instanc@ 6 E z Z V j Z fe}}: MySQL Slave SQL Thread has sto9 . {p !!!\"

      description: \"检测MySQL主从SQL线程运行状态\"

&nbs[ j 3 G | O + , Ip; - alert: MySQL Slave De$ 8 = 2 $ M 3lay Status 

    expr: mysql_slave_status_sql_delg y * Zay == 30

&nF + { Z vbsp;   for:; T ! ] N ; 5s 

&nw & d U / U Vbsp;   labels:

    &nbs, P d 8 k g _p; severity: warning

&nbsF X z | X Q mp;   annotations: 

     9 f D r D q S 3 summary: \"{{$labels.instance}}: MySQL Slave Delay has more than 30s !!!\"c } c

    &nb S t Y C ; wsp; description: \"检测MySQL主从延时状态\"

&nbsx ` ]p; - alert[ k y B Y: Myb q 8sql_Too_Many_ConY p w V I F Hnections

  &nY K {bsp; expr: rate(mysql_global_status_threads_connected[5m]v { K P } S *) > 200

&nb+ s hsp;   for: 2m

    labels:

      sev^ e 4 = ? ^ 9 ) ,erity: warning

  &nbX u T 8 O C ]sp; annotations:

    &nbs! l 9 % v d b ^ _p; summa@ ! n 7 L p nry: \"{{$labels.instance}}: 连接数过多\"

  &nbsL G V j y -p;   descrW a L h q 4 Jiption: \"{{$labels.instance}}:; 9 t f @ P X Y 连接数过多,请处理 ,(current value is:` 0 z R H J g S i {{ $value }})\"  

&nbt . H d isp; - alert: Mysqlt ) p S ` c_Too_Many_slow_queries

    expr: rate(mysql_global_status_slow_queries[5mV s @ | J # - o r]) > 3J y i | )

    for: 2m

    labels:

      severity: warning

    annotatiop A C n b O b +ns:

      summary: \"{{$labels.ins) { x _ 0 0 ytance}}: 慢查询有点多,请检查处理\"

      description: \"{{$c F K - glabels.instance}}: Mysql slow_queries is more than 3 per sec! Q U ~ w 8on4 | Y n A z 9 ed ,(current value is: {{ $value }})\"

添加规则= ` j a X Z到prometheui K [s:

rule_files:

  - \"rules/*.yml\"&nq _ ] 6 g xbsp;

打开web ui我们可以看到规则生效了:

基于Prometheus构建MySQL可视化监控平台(已用于线上环境)

总结

到此监控mysql的d U @ R / ; c t相关状态已经完成,大家可以根据mysql更多的监_ $ k i } 3控指标去完善自己的监控,当然这一套就是我用在线上环境的,可以参考参考。

作者 | 罗辉

来源丨B 9 3https://blog.51cto.com/xiaoluogez o w P s k v p E/2476375

dbaplus社群欢迎广大技术人员投稿,投稿邮箱:editor@dbaplus.cn


随着人工智能的兴起,运维迎来了新的契机,想破解运维转型困局,让Gdevops全球敏捷运维峰会北京站给你新思路:

  • 《浙江移动AIOps实践》浙江移动云计算中心NOC及AIOps负责人 潘宇虹
  • 《数据智能时代:构建能力开放的运营商大数据DataOps| * ] # ; I p体系》中国联通大数据基( f c C础平台负责人k 4 w . : /资深架构师 尹正军
  • 《云时代下,传统行业的运维转型,如何破局?》新炬网络董事/副总经理 程永新
  • 《银行日志监控系统优化手记》中国银行DevOp# = f 9 ss负责人 付大f z w Q x亮和中国银行 高级软件工程师 李晓宁
  • 《民生银行智能运维平台实践之路》民生银k + C / _行智能运维平台负责人/应用运维专家 张舒伟
  • 《建设敏捷型消费金融中台及云原生下的DevOps实践》中邮消费金融总经理助理 李远鑫

让我们在新技术的冲击下站o 3 G ] U稳脚跟,攀登运维高峰!那么2020年9月11日,我们在北京不见不散。

基于Prometheus构建MySQL可视化监控平台(已用于线上环境)

上一篇

民国时期的四大渣男,一个比一个有才,却一个比一个绝情

下一篇

使用 ThreadLocal如何避免内存泄露?

你也可能喜欢

  • 暂无相关文章!

发表评论

您的电子邮件地址不会被公开。 必填项已用 * 标注

提示:点击验证后方可评论!

插入图片
返回顶部