使用 Grafana 展示多个TiDB集群的告警

作者: yangzhj 原文来源: https://tidb.net/blog/229e283c

背景

在日常运维工作中,我们有时需要将多个生产集群的告警信息展示在一起,统一集中观察和分析TiDB 集群的告警情况。

本文将通过 Grafana 的多数据源功能来将多个TiDB 集群的 emergency级别的告警信息展示到一张 Grafana Dashboard 中。

实现过程示例

首先需要选择某个集群的 grafana 创建 Dashboard。

创建dashboard

创建panel

配置panel

添加其他tidb集群的数据源

在面板中增加其他数据源的监控指标

添加其他监控指标的面板

其他监控指标面板的方式与上述示例相同,不再重复描述。

示例Dashboard配置

JSON 复制代码
{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": null,
  "graphTooltip": 0,
  "id": 27,
  "links": [],
  "panels": [
    {
      "datasource": "-- Mixed --",
      "description": "",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "none",
            "hideFrom": {
              "graph": false,
              "legend": false,
              "tooltip": false
            },
            "lineInterpolation": "stepAfter",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 4,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "always",
            "spanNulls": true
          },
          "mappings": [
            {
              "from": "",
              "id": 1,
              "text": "告警中",
              "to": "",
              "type": 1,
              "value": "1"
            }
          ],
          "max": 1,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "graph": {},
        "legend": {
          "calcs": [
            "lastNotNull"
          ],
          "displayMode": "table",
          "placement": "right"
        },
        "tooltipOptions": {
          "mode": "multi"
        }
      },
      "pluginVersion": "7.5.11",
      "targets": [
        {
          "datasource": "test657",
          "exemplar": false,
          "expr": "ALERTS{alertname=\"TiDB_server_is_down\"}",
          "instant": false,
          "interval": "",
          "legendFormat": "test657-{{alertstate}}",
          "queryType": "randomWalk",
          "refId": "A"
        },
        {
          "datasource": "onemirror657",
          "exemplar": true,
          "expr": "ALERTS{alertname=\"TiDB_server_is_down\"}",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "interval": "",
          "legendFormat": "onemirror657-{{alertstate}}",
          "refId": "B"
        }
      ],
      "timeFrom": null,
      "timeShift": null,
      "title": "TiDB_server_is_down",
      "type": "timeseries"
    }
  ],
  "refresh": false,
  "schemaVersion": 27,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "New dashboard Copy",
  "uid": "RPbLfznHk",
  "version": 5
}

询问AI

相关推荐
Lsir10110_1 小时前
【Linux】中断 —— 操作系统的运行基石
linux·运维·嵌入式硬件
Sheffield1 小时前
command和shell模块到底区别在哪?
linux·云计算·ansible
历程里程碑1 小时前
Linux20 : IO
linux·c语言·开发语言·数据结构·c++·算法
郝学胜-神的一滴1 小时前
深入浅出:使用Linux系统函数构建高性能TCP服务器
linux·服务器·开发语言·网络·c++·tcp/ip·程序人生
承渊政道1 小时前
Linux系统学习【Linux系统的进度条实现、版本控制器git和调试器gdb介绍】
linux·开发语言·笔记·git·学习·gitee
技术路上的探险家1 小时前
Ubuntu下Docker与NVIDIA Container Toolkit完整安装教程(含国内源适配)
linux·ubuntu·docker
未来之窗软件服务1 小时前
计算机等级考试—高频英语词汇—东方仙盟练气期
数据库·计算机软考·东方仙盟
lekami_兰1 小时前
MySQL 长事务:藏在业务里的性能 “隐形杀手”
数据库·mysql·go·长事务
代码AC不AC1 小时前
【Linux】深入理解缓冲区
linux·缓冲区·标准错误
Doro再努力1 小时前
【Linux操作系统12】Git版本控制与GDB调试:从入门到实践
linux·运维·服务器·git·vim