模拟官网编写自定义Grafana Dashboard

前言

我们想编写自定义的Dashboard,类似于官网那样下载的Dashboard,并且能移值到机器主机,如何实现了?

bash 复制代码
## 官网dashboard
https://grafana.com/grafana/dashboards/

编写

先在虚拟机写好Dashboard 然后下载。json文件如下:

bash 复制代码
{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      },
      {
        "datasource": {
          "type": "prometheus",
          "uid": "c043a946-45f8-4729-9d1b-0c24ffa095c3"
        },
        "enable": true,
        "iconColor": "red",
        "name": "New annotation"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 35,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 8,
      "panels": [],
      "title": "CPU / Mem / Disk ",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "c043a946-45f8-4729-9d1b-0c24ffa095c3"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
    

.....

参考官方下载的Dashboard改写

在 annotations 上加入:

bash 复制代码
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "6.1.6"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": ""
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "singlestat",
      "name": "Singlestat",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    }
  ],

同时把数据源改成如下:

bash 复制代码
"datasource": "${DS_PROMETHEUS}"

同时去掉uid:

bash 复制代码
"uid": "c043a946-45f8-4729-9d1b-0c24ffa095c3"
相关推荐
川石课堂软件测试18 小时前
性能测试|docker容器下搭建JMeter+Grafana+Influxdb监控可视化平台
运维·javascript·深度学习·jmeter·docker·容器·grafana
Walden-20202 天前
构建基于 DCGM-Exporter, Node exporter,PROMETHEUS 和 GRAFANA 构建算力监控系统
docker·容器·grafana·prometheus
牛角上的男孩2 天前
部署Prometheus、Grafana、Zipkin、Kiali监控度量Istio
grafana·prometheus·istio
小安运维日记6 天前
Linux云计算 |【第五阶段】CLOUD-DAY10
linux·运维·云计算·k8s·grafana·prometheus
川石课堂软件测试7 天前
性能测试|linux服务器搭建JMeter+Grafana+Influxdb监控可视化平台
linux·服务器·python·jmeter·机器学习·grafana·1024程序员节
無爲謂7 天前
入门 | Kafka数据使用vector消费到Loki中使用grafana展示
分布式·kafka·vector·grafana·loki·日志存储·es限制解决办法
typ20048 天前
promtail+Loki+Grafana
grafana
Mr. G K11 天前
【grafana+Prometheus(普罗米修斯)实现监控功能】
grafana·prometheus
再ZzZ11 天前
Docker快速安装Grafana
服务器·docker·grafana·1024程序员节
编程泓哥12 天前
grafana 8.0 添加钉钉告警
钉钉·grafana