Grafana系列:在grafana7.x中配置一个如同Node Exporter中的table
Posted 不识君的荒漠
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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_countCluster=\\"$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上通过可视化的方式,增添自己的指标,设置列,随意配置了。
如果有多个指标,要拼接到一行,也是很容易的,如下:
以上是关于Grafana系列:在grafana7.x中配置一个如同Node Exporter中的table的主要内容,如果未能解决你的问题,请参考以下文章
Grafana系列:如何去定义并配置更适合自己监控使用的变量