Prometheus入门
发布日期:2021-06-29 19:26:07 浏览次数:2 分类:技术文章

本文共 66639 字,大约阅读时间需要 222 分钟。

Prometheus(普罗米修斯)这款开源监控工具,名字和功能一样酷,本文是一个干货入门,动手来部署一个实验环境。用Prometheus+Grafana来监控MySQL。 这里安利一波docker 和 vagrant ,实在是开发的利器,校长用了都说好!

Prometheus 简介

废话不多说了,首先Prometheus,它支持多维度的指标数据模型,服务端通过HTTP协议定时拉取数据后,通过灵活的查询语言,实现监控的目的。

客户端记录相关数据,并提供对外查询接口,服务端则通过服务器发现客户端,并定时抓取形成时序数据存储起来,最后通过可视化工具加以展现,其整体架构如下图:

Prometheus 可以做什么

  • 在业务层用作埋点系统

Prometheus支持各个主流开发语言(Go,java,python,ruby官方提供客户端,其他语言有第三方开源客户端)。我们可以通过客户端方面的对核心业务进行埋点。如下单流程、添加购物车流程。

  • 在应用层用作应用监控系统

一些主流应用可以通过官方或第三方的导出器,来对这些应用做核心指标的收集。如redis,mysql。

  • 在系统层用作系统监控

除了常用软件, prometheus也有相关系统层和网络层exporter,用以监控服务器或网络。

  • 集成其他的监控

prometheus还可以通过各种exporte,集成其他的监控系统,收集监控数据,如AWS CloudWatch,JMX,Pingdom等等。

Prometheus 入门案例

这里我们使用docker来自动构建,这里不推荐使用windows版本的docker,开始我也是在win环境下试的,但是无奈,总是无法正确映射文件到容器,换了ubuntu,就丝一样顺滑了。

首先看一下目录结构,docker-compose.yml 是容器启动文件,prometheus.yml 是prometheus的配置文件,另外一个是grafana与容器交互的文件,后面我们详细说。

docker-compose.yml 的内容如下,包含4个容器,prometheus,grafana,mysql exporter 和 mysql 。其中 mysql exporter是prometheus的扩展程序,我粗略的扫了一下源码,他通过读取mysql的binlog以及其他方式,获取到必要信息,然后并对外提供监控接口的。这里使用20001和20002为prometheus和grafana的对外端口。

version: '2'

services:

  exporter:

    container_name: mysql-exporter-dev

    image: prom/mysqld-exporter

    environment:

      # 这里指定的是要监控的 MySQL 数据库,这里我们以启动的 test-mysql 容器为示范。

      # 实际应用当中,应该配置为具体的数据库实例。

      - DATA_SOURCE_NAME=root:root@(test-mysql:3306)/

  prometheus:

    container_name: prometheus

    image: prom/prometheus

    ports:

      - "20001:9090"

    volumes:

      - ./prometheus.yml:/etc/prometheus/prometheus.yml

  grafana:

    container_name: grafana

    image: grafana/grafana

    environment:

      # 配置 Grafana 的默认根 URL。

      - GF_SERVER_ROOT_URL=http://localhost:20002

      # 配置 Grafana 的默认 admin 密码。

      - GF_SECURITY_ADMIN_PASSWORD=admin

    ports:

      - "20002:3000"

    # 映射 Grafana 的数据文件,方便后面进行更改。

    volumes:

      - ./grafana:/var/lib/grafana

  # 本服务只是用于演示,实际使用请注释掉本服务。

  mysql:

    container_name: test-mysql

    image: mysql

    environment:

      - MYSQL_ROOT_PASSWORD=root

prometheus.yml 的配置内容如下,这里配置了2个target,分别是prometheus自身和mysql exporter

global:

  scrape_interval:     15s

  evaluation_interval: 15s

alerting:

  alertmanagers:

  - static_configs:

    - targets:

      # - alertmanager:9093

scrape_configs:

  # Prometheus 监控配置

  - job_name: 'prometheus'

    static_configs:

      - targets: ['prometheus:9090']

  # MySQL 监控配置

  - job_name: 'mysql'

    # 抓取间隔

    scrape_interval: 5s

    static_configs:

      # 这里配置的是具体的 MySQL Exporter 的地址,在之前的 docker compose 文件

      # 定义当中,mysql exporter 的容器名为 mysql-exporter-dev。

      - targets: ['mysql-exporter-dev:9104']

切记,执行之前,将grafana的权限设置成777,以避免不必要的麻烦

访问localhost:20002 端口,这里建议配置ip。grafana支持prometheus作为数据源。

配置prometheus服务

导入mysql监控仪表盘,我将代码贴到了下面

结果还是蛮漂亮

监控仪表盘代码:

{

  "annotations": {

    "list": [

      {

        "builtIn": 1,

        "datasource": "-- Grafana --",

        "enable": true,

        "hide": false,

        "iconColor": "#e0752d",

        "limit": 100,

        "name": "PMM Annotations",

        "showIn": 0,

        "tags": [

          "pmm_annotation"

        ],

        "type": "tags"

      }

    ]

  },

  "description": "Dashboard from Percona Monitoring and Management project. ",

  "editable": true,

  "gnetId": 7362,

  "graphTooltip": 1,

  "id": 10,

  "iteration": 1547173235420,

  "links": [

    {

      "icon": "dashboard",

      "includeVars": true,

      "keepTime": true,

      "tags": [

        "QAN"

      ],

      "targetBlank": false,

      "title": "Query Analytics",

      "type": "link",

      "url": "/graph/dashboard/db/_pmm-query-analytics"

    },

    {

      "asDropdown": true,

      "includeVars": true,

      "keepTime": true,

      "tags": [

        "OS"

      ],

      "targetBlank": false,

      "title": "OS",

      "type": "dashboards"

    },

    {

      "asDropdown": true,

      "includeVars": true,

      "keepTime": true,

      "tags": [

        "MySQL"

      ],

      "targetBlank": false,

      "title": "MySQL",

      "type": "dashboards"

    },

    {

      "asDropdown": true,

      "includeVars": true,

      "keepTime": true,

      "tags": [

        "MongoDB"

      ],

      "targetBlank": false,

      "title": "MongoDB",

      "type": "dashboards"

    },

    {

      "asDropdown": true,

      "includeVars": true,

      "keepTime": true,

      "tags": [

        "HA"

      ],

      "targetBlank": false,

      "title": "HA",

      "type": "dashboards"

    },

    {

      "asDropdown": true,

      "includeVars": true,

      "keepTime": true,

      "tags": [

        "Cloud"

      ],

      "targetBlank": false,

      "title": "Cloud",

      "type": "dashboards"

    },

    {

      "asDropdown": true,

      "includeVars": true,

      "keepTime": true,

      "tags": [

        "Insight"

      ],

      "targetBlank": false,

      "title": "Insight",

      "type": "dashboards"

    },

    {

      "asDropdown": true,

      "includeVars": true,

      "keepTime": true,

      "tags": [

        "PMM"

      ],

      "targetBlank": false,

      "title": "PMM",

      "type": "dashboards"

    }

  ],

  "panels": [

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 0

      },

      "id": 382,

      "panels": [],

      "repeat": null,

      "title": "总览",

      "type": "row"

    },

    {

      "cacheTimeout": null,

      "colorBackground": false,

      "colorValue": true,

      "colors": [

        "rgba(245, 54, 54, 0.9)",

        "rgba(237, 129, 40, 0.89)",

        "rgba(50, 172, 45, 0.97)"

      ],

      "datasource": "Prometheus",

      "decimals": 1,

      "description": "mysqld 服务器进程最后一次重启的时间。",

      "editable": true,

      "error": false,

      "format": "s",

      "gauge": {

        "maxValue": 100,

        "minValue": 0,

        "show": false,

        "thresholdLabels": false,

        "thresholdMarkers": true

      },

      "gridPos": {

        "h": 4,

        "w": 6,

        "x": 0,

        "y": 1

      },

      "height": "125px",

      "id": 12,

      "interval": "$interval",

      "links": [],

      "mappingType": 1,

      "mappingTypes": [

        {

          "name": "value to text",

          "value": 1

        },

        {

          "name": "range to text",

          "value": 2

        }

      ],

      "maxDataPoints": 100,

      "nullPointMode": "connected",

      "nullText": null,

      "postfix": "s",

      "postfixFontSize": "80%",

      "prefix": "",

      "prefixFontSize": "80%",

      "rangeMaps": [

        {

          "from": "null",

          "text": "N/A",

          "to": "null"

        }

      ],

      "sparkline": {

        "fillColor": "rgba(31, 118, 189, 0.18)",

        "full": false,

        "lineColor": "rgb(31, 120, 193)",

        "show": false

      },

      "tableColumn": "",

      "targets": [

        {

          "calculatedInterval": "10m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_status_uptime{instance=\"$host\"}",

          "format": "time_series",

          "interval": "5m",

          "intervalFactor": 1,

          "legendFormat": "",

          "metric": "",

          "refId": "A",

          "step": 300

        }

      ],

      "thresholds": "300,3600",

      "title": "MySQL 正常运行时间",

      "transparent": false,

      "type": "singlestat",

      "valueFontSize": "80%",

      "valueMaps": [],

      "valueName": "current"

    },

    {

      "cacheTimeout": null,

      "colorBackground": false,

      "colorValue": false,

      "colors": [

        "rgba(245, 54, 54, 0.9)",

        "rgba(237, 129, 40, 0.89)",

        "rgba(50, 172, 45, 0.97)"

      ],

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "**Current QPS**\n\n根据 MySQL 的 ``SHOW STATUS`` 命令所返回的查询结果计算,它是服务器在最后一秒内执行的查询语句数。\n\n这个值包括存储过程当中所执行的 SQL 语句数量,与 ``Questions`` 所统计的结果不同,他不包含 ``COM_PING `` 与 ``COM_STATISTICS `` 命令返回的结果。",

      "editable": true,

      "error": false,

      "format": "short",

      "gauge": {

        "maxValue": 100,

        "minValue": 0,

        "show": false,

        "thresholdLabels": false,

        "thresholdMarkers": true

      },

      "gridPos": {

        "h": 4,

        "w": 6,

        "x": 6,

        "y": 1

      },

      "height": "125px",

      "id": 13,

      "interval": "$interval",

      "links": [

        {

          "targetBlank": true,

          "title": "MySQL Server Status Variables",

          "type": "absolute",

          "url": "https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html#statvar_Queries"

        }

      ],

      "mappingType": 1,

      "mappingTypes": [

        {

          "name": "value to text",

          "value": 1

        },

        {

          "name": "range to text",

          "value": 2

        }

      ],

      "maxDataPoints": 100,

      "nullPointMode": "connected",

      "nullText": null,

      "postfix": "",

      "postfixFontSize": "50%",

      "prefix": "",

      "prefixFontSize": "80%",

      "rangeMaps": [

        {

          "from": "null",

          "text": "N/A",

          "to": "null"

        }

      ],

      "sparkline": {

        "fillColor": "rgba(31, 118, 189, 0.18)",

        "full": false,

        "lineColor": "rgb(31, 120, 193)",

        "show": true

      },

      "tableColumn": "",

      "targets": [

        {

          "calculatedInterval": "10m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_queries{instance=\"$host\"}[$interval]) or irate(mysql_global_status_queries{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "",

          "metric": "",

          "refId": "A",

          "step": 20

        }

      ],

      "thresholds": "35,75",

      "title": "当前的 QPS",

      "transparent": false,

      "type": "singlestat",

      "valueFontSize": "80%",

      "valueMaps": [],

      "valueName": "current"

    },

    {

      "cacheTimeout": null,

      "colorBackground": false,

      "colorValue": false,

      "colors": [

        "rgba(50, 172, 45, 0.97)",

        "rgba(237, 129, 40, 0.89)",

        "rgba(245, 54, 54, 0.9)"

      ],

      "datasource": "Prometheus",

      "decimals": 0,

      "description": "InnoDB 维护了一个缓冲池,用于在内存当中进行数据缓存与索引。\n\n了解 InnoDB 缓冲池是如何工作地,就可以利用它将频繁访问的数据存储在内存当中。这也是 MySQL 性能调优的重要一个技巧。\n\n最终的目的就是缓存结果,在大多数情况下,他的值应该是主机内存的 60% ~ 90% 之间。",

      "editable": true,

      "error": false,

      "format": "bytes",

      "gauge": {

        "maxValue": 100,

        "minValue": 0,

        "show": false,

        "thresholdLabels": false,

        "thresholdMarkers": true

      },

      "gridPos": {

        "h": 4,

        "w": 6,

        "x": 12,

        "y": 1

      },

      "height": "125px",

      "id": 51,

      "interval": "$interval",

      "links": [

        {

          "targetBlank": true,

          "title": "Tuning the InnoDB Buffer Pool Size",

          "type": "absolute",

          "url": "https://www.percona.com/blog/2015/06/02/80-ram-tune-innodb_buffer_pool_size/"

        }

      ],

      "mappingType": 1,

      "mappingTypes": [

        {

          "name": "value to text",

          "value": 1

        },

        {

          "name": "range to text",

          "value": 2

        }

      ],

      "maxDataPoints": 100,

      "nullPointMode": "connected",

      "nullText": null,

      "postfix": "",

      "postfixFontSize": "50%",

      "prefix": "",

      "prefixFontSize": "80%",

      "rangeMaps": [

        {

          "from": "null",

          "text": "N/A",

          "to": "null"

        }

      ],

      "sparkline": {

        "fillColor": "rgba(31, 118, 189, 0.18)",

        "full": false,

        "lineColor": "rgb(31, 120, 193)",

        "show": false

      },

      "tableColumn": "",

      "targets": [

        {

          "calculatedInterval": "10m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_variables_innodb_buffer_pool_size{instance=\"$host\"}",

          "format": "time_series",

          "interval": "5m",

          "intervalFactor": 1,

          "legendFormat": "",

          "metric": "",

          "refId": "A",

          "step": 300

        }

      ],

      "thresholds": "90,95",

      "title": "InnoDB 缓冲池大小",

      "transparent": false,

      "type": "singlestat",

      "valueFontSize": "80%",

      "valueMaps": [],

      "valueName": "current"

    },

    {

      "cacheTimeout": null,

      "colorBackground": false,

      "colorValue": true,

      "colors": [

        "rgba(245, 54, 54, 0.9)",

        "rgba(237, 129, 40, 0.89)",

        "rgba(50, 172, 45, 0.97)"

      ],

      "datasource": "Prometheus",

      "decimals": 0,

      "description": "**InnoDB Buffer Pool Size % of Total RAM**\n\nInnoDB maintains a storage area called the buffer pool for caching data and indexes in memory.  Knowing how the InnoDB buffer pool works, and taking advantage of it to keep frequently accessed data in memory, is one of the most important aspects of MySQL tuning. The goal is to keep the working set in memory. In most cases, this should be between 60%-90% of available memory on a dedicated database host, but depends on many factors.",

      "editable": true,

      "error": false,

      "format": "percent",

      "gauge": {

        "maxValue": 100,

        "minValue": 0,

        "show": false,

        "thresholdLabels": false,

        "thresholdMarkers": true

      },

      "gridPos": {

        "h": 4,

        "w": 6,

        "x": 18,

        "y": 1

      },

      "height": "125px",

      "id": 52,

      "interval": "$interval",

      "links": [

        {

          "targetBlank": true,

          "title": "Tuning the InnoDB Buffer Pool Size",

          "type": "absolute",

          "url": "https://www.percona.com/blog/2015/06/02/80-ram-tune-innodb_buffer_pool_size/"

        }

      ],

      "mappingType": 1,

      "mappingTypes": [

        {

          "name": "value to text",

          "value": 1

        },

        {

          "name": "range to text",

          "value": 2

        }

      ],

      "maxDataPoints": 100,

      "nullPointMode": "connected",

      "nullText": null,

      "postfix": "",

      "postfixFontSize": "50%",

      "prefix": "",

      "prefixFontSize": "80%",

      "rangeMaps": [

        {

          "from": "null",

          "text": "N/A",

          "to": "null"

        }

      ],

      "repeat": null,

      "sparkline": {

        "fillColor": "rgba(31, 118, 189, 0.18)",

        "full": false,

        "lineColor": "rgb(31, 120, 193)",

        "maxValue": 100,

        "minValue": 0,

        "show": true

      },

      "tableColumn": "",

      "targets": [

        {

          "calculatedInterval": "10m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "(mysql_global_variables_innodb_buffer_pool_size{instance=\"$host\"} * 100) / on (instance) node_memory_MemTotal_bytes{instance=\"$host\"}",

          "format": "time_series",

          "interval": "5m",

          "intervalFactor": 1,

          "legendFormat": "",

          "metric": "",

          "refId": "A",

          "step": 300

        }

      ],

      "thresholds": "40,80",

      "title": "Buffer Pool Size of Total RAM",

      "transparent": false,

      "type": "singlestat",

      "valueFontSize": "80%",

      "valueMaps": [],

      "valueName": "current"

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 5

      },

      "id": 383,

      "panels": [],

      "repeat": null,

      "title": "连接数",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 0,

      "description": "注释\n\nMySQL 默认的最大连接数为 151,增加这个值的话,会导致 mysqld 所需要的文件描述符数量。当文件描述符剩余不可用的时候,mysqld 会自动降低最大连接数。\n\n实质上 mysqld 允许 (最大连接数 + 1) 个连接,额外的 1 个连接是保留给 root 用户使用的。\n\n服务器最大连接记录是 mysqld 自启动以来同时最大使用的连接数记录。(不论成功与否)",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 9,

        "w": 12,

        "x": 0,

        "y": 6

      },

      "height": "250px",

      "id": 92,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [

        {

          "targetBlank": true,

          "title": "MySQL Server System Variables",

          "type": "absolute",

          "url": "https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_connections"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [

        {

          "alias": "Max Connections",

          "fill": 0

        }

      ],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "max(max_over_time(mysql_global_status_threads_connected{instance=\"$host\"}[$interval])  or mysql_global_status_threads_connected{instance=\"$host\"} )",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "当前连接数",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_status_max_used_connections{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "服务器最大连接记录",

          "metric": "",

          "refId": "C",

          "step": 20,

          "target": ""

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_variables_max_connections{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "最大连接数",

          "metric": "",

          "refId": "B",

          "step": 20,

          "target": ""

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 连接数统计",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "cumulative"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "label": "",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "label": "",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "``已连接的线程数`` 是打开的连接数,而 ``运行中的线程数`` 则是未休眠的线程数统计。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 9,

        "w": 12,

        "x": 12,

        "y": 6

      },

      "id": 10,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": true,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [

        {

          "alias": "Peak Threads Running",

          "color": "#E24D42",

          "lines": false,

          "pointradius": 1,

          "points": true

        },

        {

          "alias": "Peak Threads Connected",

          "color": "#1F78C1"

        },

        {

          "alias": "Avg Threads Running",

          "color": "#EAB839"

        }

      ],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "max_over_time(mysql_global_status_threads_connected{instance=\"$host\"}[$interval]) or\nmax_over_time(mysql_global_status_threads_connected{instance=\"$host\"}[5m])",

          "format": "time_series",

          "hide": false,

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "已连接的线程数",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "max_over_time(mysql_global_status_threads_running{instance=\"$host\"}[$interval]) or\nmax_over_time(mysql_global_status_threads_running{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "运行中的线程数",

          "metric": "",

          "refId": "B",

          "step": 20

        },

        {

          "expr": "avg_over_time(mysql_global_status_threads_running{instance=\"$host\"}[$interval]) or \navg_over_time(mysql_global_status_threads_running{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "平均运行的线程数",

          "refId": "C",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 活动的线程数",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": [

          "total"

        ]

      },

      "yaxes": [

        {

          "format": "short",

          "label": "Threads",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "label": "",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": false

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 15

      },

      "id": 384,

      "panels": [],

      "repeat": null,

      "title": "表锁定",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": null,

      "description": "MySQL 服务器执行的查询语句统计,这只包含客户端发送的查询请求,而不包括存储过程当中执行的语句数。\n\n该统计与 QPS 统计的信息不同,此图表不计算以下命令:\n* ``COM_PING``\n* ``COM_STATISTICS``\n* ``COM_STMT_PREPARE``\n* ``COM_STMT_CLOSE``\n* ``COM_STMT_RESET``",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 9,

        "w": 12,

        "x": 0,

        "y": 16

      },

      "id": 53,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [

        {

          "targetBlank": true,

          "title": "MySQL Queries and Questions",

          "type": "absolute",

          "url": "https://www.percona.com/blog/2014/05/29/how-mysql-queries-and-questions-are-measured/"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_questions{instance=\"$host\"}[$interval]) or irate(mysql_global_status_questions{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "查询数",

          "metric": "",

          "refId": "A",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 查询数",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "``The thread_cache_size`` 变量用于配置服务器应该缓存多少个线程来进行复用。当客户端断开连接的时候,如果线程缓存池没有满的话则将该线程放入线程缓存池当中。\n\n它在 MySQL 5.6.8 以上版本会自动调整大小 (上限为 100)。\n\n如果线程池有可用线程的话,他会优先从缓存池当中拿取线程处理。并且只有在线程缓存池当中没有可用线程的时候才会创建新的线程。\n\n* *Threads_created*: 为处理连接请求而创建的线程数量。\n* *Threads_cached*: 已缓存的线程数量。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 9,

        "w": 12,

        "x": 12,

        "y": 16

      },

      "id": 11,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [

        {

          "title": "Tuning information",

          "type": "absolute",

          "url": "https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_thread_cache_size"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [

        {

          "alias": "Threads Created",

          "fill": 0

        }

      ],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_variables_thread_cache_size{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "线程缓存池大小",

          "metric": "",

          "refId": "B",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_status_threads_cached{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "已经缓存的线程",

          "metric": "",

          "refId": "C",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_threads_created{instance=\"$host\"}[$interval]) or irate(mysql_global_status_threads_created{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "已创建的线程",

          "metric": "",

          "refId": "A",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 线程缓存",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "transparent": false,

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 25

      },

      "id": 385,

      "panels": [],

      "repeat": null,

      "title": "临时对象",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 9,

        "w": 12,

        "x": 0,

        "y": 26

      },

      "id": 22,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_created_tmp_tables{instance=\"$host\"}[$interval]) or irate(mysql_global_status_created_tmp_tables{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "创建的临时表",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_created_tmp_disk_tables{instance=\"$host\"}[$interval]) or irate(mysql_global_status_created_tmp_disk_tables{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "创建到硬盘的临时表",

          "metric": "",

          "refId": "B",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_created_tmp_files{instance=\"$host\"}[$interval]) or irate(mysql_global_status_created_tmp_files{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "创建临时文件",

          "metric": "",

          "refId": "C",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 临时对象",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "基于索引进行 Select 比全表扫描更加有效,在这个图表当中看到的是未使用索引导致的 Select 查询统计。\n\n* ***Select Scan*** 是导致进行全表扫描的查询语句数量,其表中的所有数据都必须被读取和丢弃,才能够返回。\n* ***Select Range*** 是使用一个范围扫描的查询数统计,这意味着 MySQL 扫描了给定范围的所有行。\n* ***Select Full Join*** 是连接查询时未使用索引的查询数统计,这通常会对性能造成重大影响。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 9,

        "w": 12,

        "x": 12,

        "y": 26

      },

      "height": "250px",

      "id": 311,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "hideZero": true,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_select_full_join{instance=\"$host\"}[$interval]) or irate(mysql_global_status_select_full_join{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Select Full Join",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_select_full_range_join{instance=\"$host\"}[$interval]) or irate(mysql_global_status_select_full_range_join{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Select Full Range Join",

          "metric": "",

          "refId": "B",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_select_range{instance=\"$host\"}[$interval]) or irate(mysql_global_status_select_range{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Select Range",

          "metric": "",

          "refId": "C",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_select_range_check{instance=\"$host\"}[$interval]) or irate(mysql_global_status_select_range_check{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Select Range Check",

          "metric": "",

          "refId": "D",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_select_scan{instance=\"$host\"}[$interval]) or irate(mysql_global_status_select_scan{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Select Scan",

          "metric": "",

          "refId": "E",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL Select 查询类型",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 35

      },

      "id": 386,

      "panels": [],

      "repeat": null,

      "title": "排序",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "由于查询结构、顺序等要求,MySQL 会在返回数据前针对数据行进行排序。\n\n这张图还显示了什么时候排序必须扫描整个表,或者需要扫描指定的范围才能够返回结果,而这些结果通常不能够根据索引来进行排序。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 9,

        "w": 12,

        "x": 0,

        "y": 36

      },

      "id": 30,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "hideZero": true,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_sort_rows{instance=\"$host\"}[$interval]) or irate(mysql_global_status_sort_rows{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Sort Rows",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_sort_range{instance=\"$host\"}[$interval]) or irate(mysql_global_status_sort_range{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Sort Range",

          "metric": "",

          "refId": "B",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_sort_merge_passes{instance=\"$host\"}[$interval]) or irate(mysql_global_status_sort_merge_passes{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Sort Merge Passes",

          "metric": "",

          "refId": "C",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_sort_scan{instance=\"$host\"}[$interval]) or irate(mysql_global_status_sort_scan{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Sort Scan",

          "metric": "",

          "refId": "D",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 排序",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "慢查询的定义是比 ``long_query_time`` 所设置的值还要慢的查询,例如你把 ``long_query_time`` 的值设置为 3 ,那么需要超过 3 秒之后才能够完成的查询就是慢查询,这些查询会被统计到本图当中。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 9,

        "w": 12,

        "x": 12,

        "y": 36

      },

      "id": 48,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "show": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_slow_queries{instance=\"$host\"}[$interval]) or irate(mysql_global_status_slow_queries{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "慢查询语句",

          "metric": "",

          "refId": "A",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 慢查询",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "cumulative"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "label": "",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "label": "",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 45

      },

      "id": 387,

      "panels": [],

      "repeat": null,

      "title": "异常信息",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "当某个客户端连接到 MySQL 时,连接异常中断,而 MySQL 会将该信息保存在异常表当中。\n\n如果没有连接异常的数量到达 ``max_connect_errors`` 的值,mysqld 将会假定有错误并且进一步阻止客户的进一步连接。如果要允许该客户端再次连接,需要执行 ``FLUSH HOSTS`` 命令。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 12,

        "x": 0,

        "y": 46

      },

      "id": 47,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_aborted_connects{instance=\"$host\"}[$interval]) or irate(mysql_global_status_aborted_connects{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "异常中断的客户端 (尝试连接)",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_aborted_clients{instance=\"$host\"}[$interval]) or irate(mysql_global_status_aborted_clients{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "异常中断的客户端 (超时)",

          "metric": "",

          "refId": "B",

          "step": 20,

          "target": ""

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 异常中断的连接",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "cumulative"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "label": "",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "label": "",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "MySQL 会因为不同的原因而使用各种锁,在这个统计图当中我们可以看到 MySQL 从存储引擎当中请求了多少个表级锁。\n\n在 InnoDB 作为存储引擎的情况下,很多时候锁其实是行锁,只会在某些特定的情况下,才会是表级锁。\n\n比较存货的锁与锁等待是非常有用的,如果锁等待正在上升,则表明您的锁有争用。否则的话,锁的波动是很正常的活动。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 12,

        "x": 12,

        "y": 46

      },

      "id": 32,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_table_locks_immediate{instance=\"$host\"}[$interval]) or irate(mysql_global_status_table_locks_immediate{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "锁",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_table_locks_waited{instance=\"$host\"}[$interval]) or irate(mysql_global_status_table_locks_waited{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "锁等待",

          "metric": "",

          "refId": "B",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 表锁定",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 53

      },

      "id": 388,

      "panels": [],

      "repeat": null,

      "title": "网络",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "在这个统计图内部我们可以看到 MySQL 产生了多少网络流量。\n\n* 出站流量是 MySQL 发送的网络流量。\n* 入站流量是 MySQL 接收的网络流量。",

      "editable": true,

      "error": false,

      "fill": 6,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 12,

        "x": 0,

        "y": 54

      },

      "id": 9,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": true,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_bytes_received{instance=\"$host\"}[$interval]) or irate(mysql_global_status_bytes_received{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "入站流量",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_bytes_sent{instance=\"$host\"}[$interval]) or irate(mysql_global_status_bytes_sent{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "出站流量",

          "metric": "",

          "refId": "B",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 网络流量",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "Bps",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "none",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": true,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "在这里你可以看到 MySQL 每小时生成了多少流量,并且通过柱状图你可以很直白的比较 MySQL 发送与接收的数据。",

      "editable": true,

      "error": false,

      "fill": 6,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 12,

        "x": 12,

        "y": 54

      },

      "height": "250px",

      "id": 381,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": false,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": true,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "increase(mysql_global_status_bytes_received{instance=\"$host\"}[1h])",

          "format": "time_series",

          "interval": "1h",

          "intervalFactor": 1,

          "legendFormat": "接收的数据",

          "metric": "",

          "refId": "A",

          "step": 3600

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "increase(mysql_global_status_bytes_sent{instance=\"$host\"}[1h])",

          "format": "time_series",

          "interval": "1h",

          "intervalFactor": 1,

          "legendFormat": "发送的数据",

          "metric": "",

          "refId": "B",

          "step": 3600

        }

      ],

      "thresholds": [],

      "timeFrom": "24h",

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 每小时的网络流量统计",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "bytes",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "none",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 61

      },

      "id": 389,

      "panels": [],

      "repeat": null,

      "title": "内存",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 0,

      "description": "***系统内存***: 整个系统总的内存。\\\n***InnoDB 缓冲池数据***: InnoDB 维护了一个缓冲池的内存区域,用于在内存中缓存数据与索引。\\\n***TokuDB 缓存***: 与 InnoDB 缓冲池相似,TokuDB 会为自己缓存分配 50 % 的内存。\\\n***索引缓冲区***: MYISAM 表的索引块缓冲区大小,由所有线程共享,其 ``key_buffer_size`` 参数是用于配置其缓冲区大小的。。\\\n***自适应哈希索引***: 当 InnoDB 注意到某些索引值被非常频繁地访问时,它会在 B-Tree 索引之上的内存中为它们构建哈希索引。\\\n ***查询缓存***: 查询缓存存储 SELECT 语句与对应的查询结果。查询缓存存在巨大的可伸缩性问题,因为只有一个线程可以同时在查询缓存中执行操作。\\\n***InnoDB 字典***: 数据字典是 InnoDB 的内部表。InnoDB 将数据字典存储在磁盘上,并在服务器运行时加载到内存中。\\\n***InnoDB 日志缓冲区***: MySQL InnoDB日志缓冲区允许事务运行,而无需在事务提交之前将日志写入磁盘。",

      "editable": true,

      "error": false,

      "fill": 6,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 24,

        "x": 0,

        "y": 62

      },

      "id": 50,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "hideEmpty": true,

        "hideZero": true,

        "max": true,

        "min": true,

        "rightSide": true,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [

        {

          "title": "Detailed descriptions about metrics",

          "type": "absolute",

          "url": "https://www.percona.com/doc/percona-monitoring-and-management/dashboard.mysql-overview.html#mysql-internal-memory-overview"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [

        {

          "alias": "System Memory",

          "fill": 0,

          "stack": false

        }

      ],

      "spaceLength": 10,

      "stack": true,

      "steppedLine": false,

      "targets": [

        {

          "expr": "node_memory_MemTotal_bytes{instance=\"$host\"}",

          "format": "time_series",

          "intervalFactor": 2,

          "legendFormat": "System Memory",

          "refId": "G",

          "step": 4

        },

        {

          "expr": "mysql_global_status_innodb_page_size{instance=\"$host\"} * on (instance) mysql_global_status_buffer_pool_pages{instance=\"$host\",state=\"data\"}",

          "format": "time_series",

          "hide": false,

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "InnoDB 缓冲池数据",

          "refId": "A",

          "step": 20

        },

        {

          "expr": "mysql_global_variables_innodb_log_buffer_size{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "InnoDB 日志缓冲区",

          "refId": "D",

          "step": 20

        },

        {

          "expr": "mysql_global_variables_innodb_additional_mem_pool_size{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 2,

          "legendFormat": "InnoDB Additional Memory Pool Size",

          "refId": "H",

          "step": 40

        },

        {

          "expr": "mysql_global_status_innodb_mem_dictionary{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "InnoDB 字典",

          "refId": "F",

          "step": 20

        },

        {

          "expr": "mysql_global_variables_key_buffer_size{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "索引缓冲区",

          "refId": "B",

          "step": 20

        },

        {

          "expr": "mysql_global_variables_query_cache_size{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "查询缓存",

          "refId": "C",

          "step": 20

        },

        {

          "expr": "mysql_global_status_innodb_mem_adaptive_hash{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "自适应哈希索引",

          "refId": "E",

          "step": 20

        },

        {

          "expr": "mysql_global_variables_tokudb_cache_size{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "TokuDB 缓存",

          "refId": "I",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 内部内存使用总览",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "bytes",

          "label": "",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "label": null,

          "logBase": 1,

          "max": null,

          "min": null,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 69

      },

      "id": 390,

      "panels": [],

      "repeat": null,

      "title": "MySQL 内部统计",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "Com_{

{xxx}} 用于表示 xxx 命令执行的次数。每种类型的语句都会有一个状态变量,例如 ``Com_delete`` 与 ``Com_update ``。\n\n而 ``Com_delete_multi`` 则与 ``Com_update_multi`` 类似,只是他们两个是用于多表的语法。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 24,

        "x": 0,

        "y": 70

      },

      "id": 14,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "hideEmpty": false,

        "hideZero": false,

        "max": true,

        "min": true,

        "rightSide": true,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [

        {

          "title": "Server Status Variables (Com_xxx)",

          "type": "absolute",

          "url": "https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html#statvar_Com_xxx"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "topk(5, rate(mysql_global_status_commands_total{instance=\"$host\"}[$interval])>0) or topk(5, irate(mysql_global_status_commands_total{instance=\"$host\"}[5m])>0)",

          "format": "time_series",

          "hide": false,

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Com_{

{ command }}",

          "metric": "",

          "refId": "B",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "执行命令排行",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": true,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "Com_{

{xxx}} 用于表示 xxx 命令执行的次数。每种类型的语句都会有一个状态变量,例如 ``Com_delete`` 与 ``Com_update ``。\n\n而 ``Com_delete_multi`` 则与 ``Com_update_multi`` 类似,只是他们两个是用于多表的语法。",

      "editable": true,

      "error": false,

      "fill": 6,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 24,

        "x": 0,

        "y": 77

      },

      "id": 39,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": true,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": false,

      "linewidth": 2,

      "links": [

        {

          "dashboard": "https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html#statvar_Com_xxx",

          "title": "Server Status Variables (Com_xxx)",

          "type": "absolute",

          "url": "https://dev.mysql.com/doc/refman/5.7/en/server-status-variables.html#statvar_Com_xxx"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": true,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "topk(5, increase(mysql_global_status_commands_total{instance=\"$host\"}[1h])>0)",

          "format": "time_series",

          "interval": "1h",

          "intervalFactor": 1,

          "legendFormat": "Com_{

{ command }}",

          "metric": "",

          "refId": "A",

          "step": 3600

        }

      ],

      "thresholds": [],

      "timeFrom": "24h",

      "timeRegions": [],

      "timeShift": null,

      "title": "每小时执行频率最高的命令",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "MySQL 处理统计是 MySQL 内部执行查询、修改、插入行和修改行、表和索引的内部统计信息。\n\n这是 MySQL 与存储引擎之间的层级。\n\n* `read_rnd_next` 是 MySQL 服务器在执行全表扫描的时候自增的指标,越高表明性能越差。\n* `read_key` 自增的时候则表明读取了一个索引。\n* `read_next` 是当存储引擎要求执行 'read the next index entry'的时候会被自增。该值越高则意味着要进行大量的索引扫描。",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 24,

        "x": 0,

        "y": 84

      },

      "id": 8,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "hideZero": true,

        "max": true,

        "min": true,

        "rightSide": true,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_handlers_total{instance=\"$host\", handler!~\"commit|rollback|savepoint.*|prepare\"}[$interval]) or irate(mysql_global_status_handlers_total{instance=\"$host\", handler!~\"commit|rollback|savepoint.*|prepare\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "{

{ handler }}",

          "metric": "",

          "refId": "J",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 处理计数",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 24,

        "x": 0,

        "y": 91

      },

      "id": 28,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "hideZero": true,

        "max": true,

        "min": true,

        "rightSide": true,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_handlers_total{instance=\"$host\", handler=~\"commit|rollback|savepoint.*|prepare\"}[$interval]) or irate(mysql_global_status_handlers_total{instance=\"$host\", handler=~\"commit|rollback|savepoint.*|prepare\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "{

{ handler }}",

          "metric": "",

          "refId": "A",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 事务处理统计",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 98

      },

      "id": 392,

      "panels": [],

      "repeat": null,

      "title": "文件与数据表",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 12,

        "x": 0,

        "y": 99

      },

      "id": 43,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_opened_files{instance=\"$host\"}[$interval]) or irate(mysql_global_status_opened_files{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "正在打开的文件",

          "metric": "",

          "refId": "A",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 读取文件统计",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 12,

        "x": 12,

        "y": 99

      },

      "id": 41,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_status_open_files{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "MySQL 打开的文件数",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_variables_open_files_limit{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "允许最大打开的文件数",

          "metric": "",

          "refId": "D",

          "step": 20

        },

        {

          "expr": "mysql_global_status_innodb_num_open_files{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "InnoDB 打开的文件数",

          "refId": "B",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL 打开的文件",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 106

      },

      "id": 393,

      "panels": [],

      "repeat": null,

      "title": "Table Openings",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "**MySQL Table Open Cache Status**\n\nThe recommendation is to set the `table_open_cache_instances` to a loose correlation to virtual CPUs, keeping in mind that more instances means the cache is split more times. If you have a cache set to 500 but it has 10 instances, each cache will only have 50 cached.\n\nThe `table_definition_cache` and `table_open_cache` can be left as default as they are auto-sized MySQL 5.6 and above (ie: do not set them to any value).",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 12,

        "x": 0,

        "y": 107

      },

      "id": 44,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [

        {

          "title": "Server Status Variables (table_open_cache)",

          "type": "absolute",

          "url": "http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_table_open_cache"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [

        {

          "alias": "Table Open Cache Hit Ratio",

          "yaxis": 2

        }

      ],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "rate(mysql_global_status_opened_tables{instance=\"$host\"}[$interval]) or irate(mysql_global_status_opened_tables{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Openings",

          "metric": "",

          "refId": "A",

          "step": 20

        },

        {

          "expr": "rate(mysql_global_status_table_open_cache_hits{instance=\"$host\"}[$interval]) or irate(mysql_global_status_table_open_cache_hits{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Hits",

          "refId": "B",

          "step": 20

        },

        {

          "expr": "rate(mysql_global_status_table_open_cache_misses{instance=\"$host\"}[$interval]) or irate(mysql_global_status_table_open_cache_misses{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Misses",

          "refId": "C",

          "step": 20

        },

        {

          "expr": "rate(mysql_global_status_table_open_cache_overflows{instance=\"$host\"}[$interval]) or irate(mysql_global_status_table_open_cache_overflows{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Misses due to Overflows",

          "refId": "D",

          "step": 20

        },

        {

          "expr": "(rate(mysql_global_status_table_open_cache_hits{instance=\"$host\"}[$interval]) or irate(mysql_global_status_table_open_cache_hits{instance=\"$host\"}[5m]))/((rate(mysql_global_status_table_open_cache_hits{instance=\"$host\"}[$interval]) or irate(mysql_global_status_table_open_cache_hits{instance=\"$host\"}[5m]))+(rate(mysql_global_status_table_open_cache_misses{instance=\"$host\"}[$interval]) or irate(mysql_global_status_table_open_cache_misses{instance=\"$host\"}[5m])))",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Table Open Cache Hit Ratio",

          "refId": "E",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL Table Open Cache Status",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "percentunit",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "**MySQL Open Tables**\n\nThe recommendation is to set the `table_open_cache_instances` to a loose correlation to virtual CPUs, keeping in mind that more instances means the cache is split more times. If you have a cache set to 500 but it has 10 instances, each cache will only have 50 cached.\n\nThe `table_definition_cache` and `table_open_cache` can be left as default as they are auto-sized MySQL 5.6 and above (ie: do not set them to any value).",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 7,

        "w": 12,

        "x": 12,

        "y": 107

      },

      "id": 42,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [

        {

          "title": "Server Status Variables (table_open_cache)",

          "type": "absolute",

          "url": "http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_table_open_cache"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_status_open_tables{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Open Tables",

          "metric": "",

          "refId": "B",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_variables_table_open_cache{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Table Open Cache",

          "metric": "",

          "refId": "C",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL Open Tables",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    },

    {

      "collapsed": false,

      "gridPos": {

        "h": 1,

        "w": 24,

        "x": 0,

        "y": 114

      },

      "id": 394,

      "panels": [],

      "repeat": null,

      "title": "MySQL Table Definition Cache",

      "type": "row"

    },

    {

      "aliasColors": {},

      "bars": false,

      "dashLength": 10,

      "dashes": false,

      "datasource": "Prometheus",

      "decimals": 2,

      "description": "**MySQL Table Definition Cache**\n\nThe recommendation is to set the `table_open_cache_instances` to a loose correlation to virtual CPUs, keeping in mind that more instances means the cache is split more times. If you have a cache set to 500 but it has 10 instances, each cache will only have 50 cached.\n\nThe `table_definition_cache` and `table_open_cache` can be left as default as they are auto-sized MySQL 5.6 and above (ie: do not set them to any value).",

      "editable": true,

      "error": false,

      "fill": 2,

      "grid": {},

      "gridPos": {

        "h": 8,

        "w": 24,

        "x": 0,

        "y": 115

      },

      "id": 54,

      "legend": {

        "alignAsTable": true,

        "avg": true,

        "current": false,

        "max": true,

        "min": true,

        "rightSide": false,

        "show": true,

        "sort": "avg",

        "sortDesc": true,

        "total": false,

        "values": true

      },

      "lines": true,

      "linewidth": 2,

      "links": [

        {

          "title": "Server Status Variables (table_open_cache)",

          "type": "absolute",

          "url": "http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_table_open_cache"

        }

      ],

      "nullPointMode": "null",

      "percentage": false,

      "pointradius": 5,

      "points": false,

      "renderer": "flot",

      "seriesOverrides": [

        {

          "alias": "Opened Table Definitions",

          "yaxis": 2

        }

      ],

      "spaceLength": 10,

      "stack": false,

      "steppedLine": false,

      "targets": [

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_status_open_table_definitions{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Open Table Definitions",

          "metric": "",

          "refId": "B",

          "step": 20

        },

        {

          "calculatedInterval": "2m",

          "datasourceErrors": {},

          "errors": {},

          "expr": "mysql_global_variables_table_definition_cache{instance=\"$host\"}",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Table Definitions Cache Size",

          "metric": "",

          "refId": "C",

          "step": 20

        },

        {

          "expr": "rate(mysql_global_status_opened_table_definitions{instance=\"$host\"}[$interval]) or irate(mysql_global_status_opened_table_definitions{instance=\"$host\"}[5m])",

          "format": "time_series",

          "interval": "$interval",

          "intervalFactor": 1,

          "legendFormat": "Opened Table Definitions",

          "refId": "A",

          "step": 20

        }

      ],

      "thresholds": [],

      "timeFrom": null,

      "timeRegions": [],

      "timeShift": null,

      "title": "MySQL Table Definition Cache",

      "tooltip": {

        "msResolution": false,

        "shared": true,

        "sort": 0,

        "value_type": "individual"

      },

      "type": "graph",

      "xaxis": {

        "buckets": null,

        "mode": "time",

        "name": null,

        "show": true,

        "values": []

      },

      "yaxes": [

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        },

        {

          "format": "short",

          "logBase": 1,

          "max": null,

          "min": 0,

          "show": true

        }

      ],

      "yaxis": {

        "align": false,

        "alignLevel": null

      }

    }

  ],

  "refresh": "1m",

  "schemaVersion": 16,

  "style": "dark",

  "tags": [

    "Percona",

    "MySQL"

  ],

  "templating": {

    "list": [

      {

        "allFormat": "glob",

        "auto": true,

        "auto_count": 200,

        "auto_min": "1s",

        "current": {

          "text": "auto",

          "value": "$__auto_interval_interval"

        },

        "datasource": "Prometheus",

        "hide": 0,

        "includeAll": false,

        "label": "Interval",

        "multi": false,

        "multiFormat": "glob",

        "name": "interval",

        "options": [

          {

            "selected": true,

            "text": "auto",

            "value": "$__auto_interval_interval"

          },

          {

            "selected": false,

            "text": "1s",

            "value": "1s"

          },

          {

            "selected": false,

            "text": "5s",

            "value": "5s"

          },

          {

            "selected": false,

            "text": "1m",

            "value": "1m"

          },

          {

            "selected": false,

            "text": "5m",

            "value": "5m"

          },

          {

            "selected": false,

            "text": "1h",

            "value": "1h"

          },

          {

            "selected": false,

            "text": "6h",

            "value": "6h"

          },

          {

            "selected": false,

            "text": "1d",

            "value": "1d"

          }

        ],

        "query": "1s,5s,1m,5m,1h,6h,1d",

        "refresh": 2,

        "skipUrlSync": false,

        "type": "interval"

      },

      {

        "allFormat": "glob",

        "allValue": null,

        "current": {

          "text": "mysql-exporter-dev:9104",

          "value": "mysql-exporter-dev:9104"

        },

        "datasource": "Prometheus",

        "definition": "",

        "hide": 0,

        "includeAll": false,

        "label": "Host",

        "multi": false,

        "multiFormat": "regex values",

        "name": "host",

        "options": [],

        "query": "label_values(mysql_up, instance)",

        "refresh": 1,

        "refresh_on_load": false,

        "regex": "",

        "skipUrlSync": false,

        "sort": 1,

        "tagValuesQuery": null,

        "tags": [],

        "tagsQuery": null,

        "type": "query",

        "useTags": false

      }

    ]

  },

  "time": {

    "from": "now-12h",

    "to": "now"

  },

  "timepicker": {

    "collapse": false,

    "enable": true,

    "hidden": false,

    "notice": false,

    "now": true,

    "refresh_intervals": [

      "5s",

      "10s",

      "30s",

      "1m",

      "5m",

      "15m",

      "30m",

      "1h",

      "2h",

      "1d"

    ],

    "status": "Stable",

    "time_options": [

      "5m",

      "15m",

      "1h",

      "6h",

      "12h",

      "24h",

      "2d",

      "7d",

      "30d"

    ],

    "type": "timepicker"

  },

  "timezone": "browser",

  "title": "MySQL 详细统计",

  "uid": "MQWgroiiz",

  "version": 9

}

参考连接:

https://www.cnblogs.com/lonelyxmas/p/10404002.html

https://www.cnblogs.com/lazio10000/p/7773571.html

转载地址:https://dafei1288.blog.csdn.net/article/details/102382717 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:零基础学Flink:监控 on Prometheus
下一篇:机器学习的敲门砖:kNN算法(下)

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月04日 23时38分39秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章