Grafana系列:在grafana7.x中配置一个如同Node Exporter中的table

前言

用过node exporter的同学,可能用过这个监控面板:Node Exporter for Prometheus Dashboard CN 20201010

资源总览下有个服务器资源总览表的面板:

这是个table类型的面板。

如果我想在自己的监控盘上也配置一个类似的table,比如监控rocketmq的消费端信息:

我用的grafana版本是7.x,默认是没这个类型的,自带的table不是这个,这个是"table-old",如下:

右下角,没有任何一个类型被选中。 

下面提供一个暴力的解决办法。

配置table-old

既然通过页面的方式,无法操作,那就换个思路,比如直接编辑json配置。

点击设置-> JSON模型

直接在这里修改。

下面是上面消费端状态的json配置:

        {
          "columns": [],
          "datasource": "Prometheus",
          "description": "",
          "fieldConfig": {
            "defaults": {
              "custom": {}
            },
            "overrides": []
          },
          "fontSize": "80%",
          "gridPos": {
            "h": 11,
            "w": 24,
            "x": 0,
            "y": 5
          },
          "id": 51,
          "pageSize": 20,
          "showHeader": true,
          "sort": {
            "col": 10,
            "desc": true
          },
          "styles": [
            {
              "$$hashKey": "object:33450",
              "alias": "消费组",
              "align": "auto",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "link": false,
              "linkTargetBlank": false,
              "linkTooltip": "消费端明细",
              "linkUrl": "d/zkVx1w_iz/rocketmq?orgId=1&var-env=${Env}&var-cluster=${Cluster}&var-broker=${broker}&var-topic=All&var-group=$group",
              "mappingType": 1,
              "pattern": "group",
              "preserveFormat": false,
              "thresholds": [],
              "type": "string",
              "unit": "short"
            },
            {
              "$$hashKey": "object:33451",
              "alias": "Topic",
              "align": "auto",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "link": false,
              "mappingType": 1,
              "pattern": "topic",
              "thresholds": [],
              "type": "string",
              "unit": "bytes"
            },
            {
              "$$hashKey": "object:33452",
              "alias": "客户端地址",
              "align": "auto",
              "colorMode": "value",
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "#37872D"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "mappingType": 1,
              "pattern": "clientAddr",
              "thresholds": [],
              "type": "string",
              "unit": "none"
            },
            {
              "$$hashKey": "object:33453",
              "alias": "客户端ID",
              "align": "auto",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "#37872D"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "mappingType": 1,
              "pattern": "clientId",
              "thresholds": [],
              "type": "string",
              "unit": "none"
            },
            {
              "$$hashKey": "object:39496",
              "alias": "消费失败量",
              "align": "auto",
              "colorMode": "cell",
              "colors": [
                "rgba(50, 172, 45, 0.97)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(245, 54, 54, 0.9)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "mappingType": 1,
              "pattern": "Value",
              "thresholds": [
                "1",
                "100"
              ],
              "type": "number",
              "unit": "short"
            },
            {
              "$$hashKey": "object:37380",
              "alias": "",
              "align": "auto",
              "colorMode": null,
              "colors": [
                "rgba(245, 54, 54, 0.9)",
                "rgba(237, 129, 40, 0.89)",
                "rgba(50, 172, 45, 0.97)"
              ],
              "dateFormat": "YYYY-MM-DD HH:mm:ss",
              "decimals": 2,
              "mappingType": 1,
              "pattern": "/.*/",
              "thresholds": [],
              "type": "hidden",
              "unit": "short"
            }
          ],
          "targets": [
            {
              "expr": "rocketmq_client_consume_fail_msg_count{Cluster=\"$cluster\",Env=\"$env\",group=~\"$group\",topic=~\"$topic\"}",
              "format": "table",
              "instant": true,
              "interval": "",
              "legendFormat": "消费失败",
              "refId": "A"
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "消费端信息",
          "transform": "table",
          "type": "table-old"
        },

 将它直接复制在json配置的panels下,比如我的:

因为这个示例用的行折叠,所以可能嵌套了,自己要据实际情况配置,放在panels下即可:

然后在grafana上保存这个json变更后的配置 ,这个监控大盘就可以看到这个类型的面板了。

之后就可以直接在grafana上通过可视化的方式,增添自己的指标,设置列,随意配置了。

如果有多个指标,要拼接到一行,也是很容易的,如下:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
以下是一个简单的文模板示例,用于在Grafana监控Node Exporter的指标: ``` { "dashboard": { "id": null, "title": "Node Exporter监控", "panels": [ { "title": "CPU使用率", "type": "graph", "targets": [ { "expr": "100 - (avg by (instance) (irate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100)", "legendFormat": "{{instance}}", "intervalFactor": 2 } ], "yaxes": [ { "format": "percent" }, { "format": "short" } ], "gridPos": { "x": 0, "y": 0, "w": 12, "h": 6 } }, { "title": "内存使用率", "type": "graph", "targets": [ { "expr": "(node_memory_MemTotal_bytes - node_memory_MemFree_bytes - node_memory_Buffers_bytes - node_memory_Cached_bytes) / node_memory_MemTotal_bytes * 100", "legendFormat": "{{instance}}", "intervalFactor": 2 } ], "yaxes": [ { "format": "percent" }, { "format": "short" } ], "gridPos": { "x": 0, "y": 6, "w": 12, "h": 6 } }, { "title": "磁盘使用率", "type": "graph", "targets": [ { "expr": "100 - (avg by (instance) (node_filesystem_avail_bytes{fstype!=\"rootfs\"} / node_filesystem_size_bytes{fstype!=\"rootfs\"}) * 100)", "legendFormat": "{{instance}}", "intervalFactor": 2 } ], "yaxes": [ { "format": "percent" }, { "format": "short" } ], "gridPos": { "x": 0, "y": 12, "w": 12, "h": 6 } } ], "time": { "from": "now-1h", "to": "now" }, "timezone": "browser", "schemaVersion": 21, "version": 0 }, "folderId": null, "overwrite": false } ``` 这个示例包括了三个面板,分别是CPU使用率、内存使用率和磁盘使用率。你可以根据需要修改面板的标题、指标和布局。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不识君的荒漠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值