From f4fb9969dcb00945f81cc22933cac8fb67188092 Mon Sep 17 00:00:00 2001 From: kongfei605 Date: Fri, 3 Jul 2026 17:26:27 +0800 Subject: [PATCH] feat(net_response): add Grafana dashboard conversion --- inputs/net_response/dashboard.json | 626 ++++++++++++++++++++- inputs/net_response/dashboard_grafana.json | 560 +++++++++++++++++- 2 files changed, 1154 insertions(+), 32 deletions(-) diff --git a/inputs/net_response/dashboard.json b/inputs/net_response/dashboard.json index 5f96e070..75b0258b 100644 --- a/inputs/net_response/dashboard.json +++ b/inputs/net_response/dashboard.json @@ -1,19 +1,611 @@ -[ - { - "name": "TCP探测", - "tags": "", - "configs": "", - "chart_groups": [ - { - "name": "Default chart group", - "weight": 0, - "charts": [ - { - "configs": "{\"targets\":[{\"refId\":\"A\",\"expr\":\"max(net_response_result_code) by (target)\",\"legend\":\"UP?\"},{\"expr\":\"max(net_response_response_time) by (target)\",\"refId\":\"C\",\"legend\":\"latency(s)\"}],\"name\":\"Targets\",\"custom\":{\"showHeader\":true,\"calc\":\"lastNotNull\",\"displayMode\":\"labelValuesToRows\",\"aggrDimension\":\"target\"},\"options\":{\"valueMappings\":[],\"standardOptions\":{}},\"overrides\":[{\"properties\":{\"valueMappings\":[{\"type\":\"special\",\"match\":{\"special\":0},\"result\":{\"text\":\"UP\",\"color\":\"#417505\"}},{\"type\":\"range\",\"match\":{\"special\":1,\"from\":1},\"result\":{\"text\":\"DOWN\",\"color\":\"#e90f0f\"}}],\"standardOptions\":{}},\"matcher\":{\"value\":\"A\"}}],\"version\":\"2.0.0\",\"type\":\"table\",\"layout\":{\"h\":4,\"w\":24,\"x\":0,\"y\":0,\"i\":\"0\"}}", - "weight": 0 +{ + "name": "Net Response 探测", + "tags": "categraf,net_response", + "note": "", + "ident": "", + "uuid": 1783070010545000, + "configs": { + "version": "3.0.0", + "var": [ + { + "name": "datasource", + "type": "datasource", + "definition": "prometheus", + "defaultValue": 1, + "label": "Datasource", + "hide": false + }, + { + "name": "target", + "type": "query", + "datasource": { + "cate": "prometheus", + "value": "${datasource}" + }, + "definition": "label_values(net_response_result_code, target)", + "reg": "", + "multi": false, + "hide": false + } + ], + "panels": [ + { + "name": "全局巡检", + "type": "row", + "layout": { + "h": 1, + "w": 24, + "x": 0, + "y": 0, + "i": "net-response-row-global", + "isResizable": true + }, + "collapsed": false, + "panels": [], + "id": "net-response-row-global" + }, + { + "name": "所有 Target 健康状态", + "type": "hexbin", + "version": "3.4.0", + "datasourceCate": "prometheus", + "datasourceValue": "${datasource}", + "targets": [ + { + "refId": "A", + "expr": "max(net_response_result_code) by (target)", + "legend": "{{target}}" + } + ], + "custom": { + "textMode": "valueAndName", + "calc": "lastNotNull", + "valueField": "Value", + "colorRange": [ + "#2c9d3d", + "#f5a623", + "#ce4f52" + ], + "reverseColorOrder": false, + "colorDomainAuto": false, + "colorDomain": [ + 0, + 1 + ] + }, + "options": { + "valueMappings": [ + { + "type": "special", + "match": { + "special": 0 + }, + "result": { + "text": "UP", + "color": "#2c9d3d" + } + }, + { + "type": "special", + "match": { + "special": 1 + }, + "result": { + "text": "TIMEOUT", + "color": "#ce4f52" + } + }, + { + "type": "special", + "match": { + "special": 2 + }, + "result": { + "text": "CONN_FAILED", + "color": "#ce4f52" + } + }, + { + "type": "special", + "match": { + "special": 3 + }, + "result": { + "text": "READ_FAILED", + "color": "#f5a623" + } + }, + { + "type": "special", + "match": { + "special": 4 + }, + "result": { + "text": "STRING_MISMATCH", + "color": "#f5a623" + } + } + ], + "standardOptions": {}, + "thresholds": { + "steps": [ + { + "color": "#2c9d3d", + "value": null, + "type": "base" + }, + { + "color": "#ce4f52", + "value": 1 + } + ] + } + }, + "layout": { + "h": 8, + "w": 12, + "x": 0, + "y": 1, + "i": "net-response-global-health", + "isResizable": true + }, + "maxPerRow": 6, + "id": "net-response-global-health", + "overrides": [] + }, + { + "name": "所有 Target 响应时间", + "type": "barGauge", + "version": "3.4.0", + "datasourceCate": "prometheus", + "datasourceValue": "${datasource}", + "targets": [ + { + "refId": "A", + "expr": "max(net_response_response_time) by (target)", + "legend": "{{target}}" + } + ], + "custom": { + "calc": "lastNotNull", + "valueField": "Value", + "serieWidth": 20, + "sortOrder": "desc", + "displayMode": "basic", + "valueMode": "color", + "otherPosition": "none" + }, + "options": { + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "#2c9d3d", + "value": null, + "type": "base" + }, + { + "color": "#f5a623", + "value": 0.1 + }, + { + "color": "#ce4f52", + "value": 0.5 + } + ] + }, + "standardOptions": { + "unit": "s" + } + }, + "layout": { + "h": 8, + "w": 12, + "x": 12, + "y": 1, + "i": "net-response-global-latency", + "isResizable": true + }, + "maxPerRow": 4, + "id": "net-response-global-latency", + "overrides": [] + }, + { + "name": "Target 当前明细", + "type": "table", + "datasourceCate": "prometheus", + "datasourceValue": "${datasource}", + "targets": [ + { + "refId": "A", + "expr": "max(net_response_result_code) by (target)", + "legend": "result_code" + }, + { + "refId": "B", + "expr": "max(net_response_response_time) by (target)", + "legend": "latency_s" + } + ], + "custom": { + "showHeader": true, + "calc": "lastNotNull", + "displayMode": "labelValuesToRows", + "aggrDimension": "target", + "tableLayout": "fixed", + "nowrap": false + }, + "options": { + "valueMappings": [], + "standardOptions": {} + }, + "overrides": [ + { + "matcher": { + "value": "A" + }, + "properties": { + "valueMappings": [ + { + "type": "special", + "match": { + "special": 0 + }, + "result": { + "text": "UP", + "color": "#2c9d3d" + } + }, + { + "type": "special", + "match": { + "special": 1 + }, + "result": { + "text": "TIMEOUT", + "color": "#ce4f52" + } + }, + { + "type": "special", + "match": { + "special": 2 + }, + "result": { + "text": "CONN_FAILED", + "color": "#ce4f52" + } + }, + { + "type": "special", + "match": { + "special": 3 + }, + "result": { + "text": "READ_FAILED", + "color": "#f5a623" + } + }, + { + "type": "special", + "match": { + "special": 4 + }, + "result": { + "text": "STRING_MISMATCH", + "color": "#f5a623" + } + } + ], + "standardOptions": {} + } + }, + { + "matcher": { + "value": "B" + }, + "properties": { + "standardOptions": { + "unit": "s" + } + } + } + ], + "layout": { + "h": 5, + "w": 24, + "x": 0, + "y": 9, + "i": "net-response-global-table", + "isResizable": true + }, + "id": "net-response-global-table" + }, + { + "name": "单 Target 详情", + "type": "row", + "layout": { + "h": 1, + "w": 24, + "x": 0, + "y": 14, + "i": "net-response-row-target", + "isResizable": true + }, + "collapsed": false, + "panels": [], + "id": "net-response-row-target" + }, + { + "name": "当前健康状态", + "type": "stat", + "datasourceCate": "prometheus", + "datasourceValue": "${datasource}", + "targets": [ + { + "refId": "A", + "expr": "max(net_response_result_code{target=\"$target\"})", + "legend": "result_code" + } + ], + "custom": { + "textMode": "value", + "colorMode": "background", + "calc": "lastNotNull", + "valueField": "Value", + "colSpan": 1, + "textSize": {} + }, + "options": { + "valueMappings": [ + { + "type": "special", + "match": { + "special": 0 + }, + "result": { + "text": "UP", + "color": "#2c9d3d" + } + }, + { + "type": "special", + "match": { + "special": 1 + }, + "result": { + "text": "TIMEOUT", + "color": "#ce4f52" + } + }, + { + "type": "special", + "match": { + "special": 2 + }, + "result": { + "text": "CONN_FAILED", + "color": "#ce4f52" + } + }, + { + "type": "special", + "match": { + "special": 3 + }, + "result": { + "text": "READ_FAILED", + "color": "#f5a623" + } + }, + { + "type": "special", + "match": { + "special": 4 + }, + "result": { + "text": "STRING_MISMATCH", + "color": "#f5a623" + } + } + ], + "standardOptions": {}, + "thresholds": { + "steps": [ + { + "color": "#2c9d3d", + "value": null, + "type": "base" + }, + { + "color": "#ce4f52", + "value": 1 + } + ] + } + }, + "layout": { + "h": 4, + "w": 8, + "x": 0, + "y": 15, + "i": "net-response-target-health", + "isResizable": true + }, + "id": "net-response-target-health", + "overrides": [] + }, + { + "name": "当前响应时间", + "type": "stat", + "datasourceCate": "prometheus", + "datasourceValue": "${datasource}", + "targets": [ + { + "refId": "A", + "expr": "max(net_response_response_time{target=\"$target\"})", + "legend": "latency_s" + } + ], + "custom": { + "textMode": "valueAndName", + "colorMode": "value", + "calc": "lastNotNull", + "colSpan": 1, + "textSize": {} + }, + "options": { + "standardOptions": { + "unit": "s" + }, + "thresholds": { + "steps": [ + { + "color": "#2c9d3d", + "value": null, + "type": "base" + }, + { + "color": "#f5a623", + "value": 0.1 + }, + { + "color": "#ce4f52", + "value": 0.5 + } + ] + } + }, + "layout": { + "h": 4, + "w": 8, + "x": 8, + "y": 15, + "i": "net-response-target-latency", + "isResizable": true + }, + "id": "net-response-target-latency", + "overrides": [] + }, + { + "name": "响应时间趋势", + "type": "timeseries", + "datasourceCate": "prometheus", + "datasourceValue": "${datasource}", + "targets": [ + { + "refId": "A", + "expr": "net_response_response_time{target=\"$target\"}", + "legend": "latency_s" + } + ], + "custom": { + "drawStyle": "lines", + "lineInterpolation": "linear", + "spanNulls": false, + "lineWidth": 2, + "fillOpacity": 0.15, + "gradientMode": "none", + "stack": "off", + "scaleDistribution": { + "type": "linear" + } + }, + "options": { + "tooltip": { + "mode": "all", + "sort": "desc" + }, + "legend": { + "displayMode": "list", + "placement": "bottom" + }, + "standardOptions": { + "unit": "s" + }, + "thresholds": { + "steps": [ + { + "color": "#2c9d3d", + "value": null, + "type": "base" + } + ] + } + }, + "overrides": [], + "layout": { + "h": 7, + "w": 12, + "x": 0, + "y": 19, + "i": "net-response-target-latency-trend", + "isResizable": true + }, + "id": "net-response-target-latency-trend" + }, + { + "name": "状态变化趋势", + "type": "timeseries", + "datasourceCate": "prometheus", + "datasourceValue": "${datasource}", + "targets": [ + { + "refId": "A", + "expr": "net_response_result_code{target=\"$target\"}", + "legend": "result_code" + } + ], + "custom": { + "drawStyle": "lines", + "lineInterpolation": "smooth", + "spanNulls": false, + "lineWidth": 2, + "fillOpacity": 0.01, + "gradientMode": "none", + "stack": "off", + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "none", + "pointSize": 5 + }, + "options": { + "tooltip": { + "mode": "single" + }, + "legend": { + "displayMode": "hidden", + "placement": "bottom", + "behaviour": "showItem", + "selectMode": "single" + }, + "standardOptions": {}, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgb(44, 157, 61)", + "value": null, + "type": "base" + } + ] + }, + "thresholdsStyle": { + "mode": "dashed" + } + }, + "overrides": [], + "layout": { + "h": 7, + "w": 12, + "x": 12, + "y": 19, + "i": "net-response-target-code-trend", + "isResizable": true + }, + "id": "net-response-target-code-trend" } - ] - } - ] + ] } - ] \ No newline at end of file +} diff --git a/inputs/net_response/dashboard_grafana.json b/inputs/net_response/dashboard_grafana.json index a0361fc2..a58adea4 100644 --- a/inputs/net_response/dashboard_grafana.json +++ b/inputs/net_response/dashboard_grafana.json @@ -24,25 +24,25 @@ "panels": [ { "id": 1, - "title": "Default chart group", + "title": "全局巡检", "type": "row", - "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 - } + }, + "collapsed": false }, { "id": 2, - "title": "Targets", - "type": "table", + "title": "所有 Target 健康状态", + "type": "stat", "gridPos": { - "h": 4, - "w": 24, + "h": 8, + "w": 12, "x": 0, - "y": 0 + "y": 1 }, "datasource": { "type": "prometheus", @@ -56,10 +56,86 @@ }, "editorMode": "code", "expr": "max(net_response_result_code) by (target)", - "legendFormat": "UP?", + "legendFormat": "{{target}}", "range": true, "refId": "A" + } + ], + "fieldConfig": { + "defaults": { + "mappings": [ + { + "type": "value", + "options": { + "0": { + "text": "UP", + "color": "green" + }, + "1": { + "text": "TIMEOUT", + "color": "red" + }, + "2": { + "text": "CONN_FAILED", + "color": "red" + }, + "3": { + "text": "READ_FAILED", + "color": "orange" + }, + "4": { + "text": "STRING_MISMATCH", + "color": "orange" + } + } + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" }, + "orientation": "auto", + "textMode": "value_and_name", + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto" + } + }, + { + "id": 3, + "title": "所有 Target 响应时间", + "type": "bargauge", + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 1 + }, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "targets": [ { "datasource": { "type": "prometheus", @@ -67,13 +143,14 @@ }, "editorMode": "code", "expr": "max(net_response_response_time) by (target)", - "legendFormat": "latency(s)", + "legendFormat": "{{target}}", "range": true, - "refId": "C" + "refId": "A" } ], "fieldConfig": { "defaults": { + "mappings": [], "thresholds": { "mode": "absolute", "steps": [ @@ -81,15 +158,143 @@ "color": "green", "value": null }, + { + "color": "orange", + "value": 0.1 + }, { "color": "red", - "value": 80 + "value": 0.5 } ] - } + }, + "unit": "s" }, "overrides": [] }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "horizontal", + "displayMode": "gradient", + "showUnfilled": true + } + }, + { + "id": 4, + "title": "Target 当前明细", + "type": "table", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 9 + }, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "editorMode": "code", + "expr": "max(net_response_result_code) by (target)", + "legendFormat": "result_code", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "editorMode": "code", + "expr": "max(net_response_response_time) by (target)", + "legendFormat": "latency_s", + "range": true, + "refId": "B" + } + ], + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + } + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "A" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "0": { + "text": "UP", + "color": "green" + }, + "1": { + "text": "TIMEOUT", + "color": "red" + }, + "2": { + "text": "CONN_FAILED", + "color": "red" + }, + "3": { + "text": "READ_FAILED", + "color": "orange" + }, + "4": { + "text": "STRING_MISMATCH", + "color": "orange" + } + } + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "B" + }, + "properties": [ + { + "id": "unit", + "value": "s" + } + ] + } + ] + }, "options": { "showHeader": true, "cellHeight": "sm", @@ -102,13 +307,315 @@ "fields": "" } } + }, + { + "id": 5, + "title": "单 Target 详情", + "type": "row", + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 14 + }, + "collapsed": false + }, + { + "id": 6, + "title": "当前健康状态", + "type": "stat", + "gridPos": { + "h": 4, + "w": 8, + "x": 0, + "y": 15 + }, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "editorMode": "code", + "expr": "max(net_response_result_code{target=\"$target\"})", + "legendFormat": "result_code", + "range": true, + "refId": "A" + } + ], + "fieldConfig": { + "defaults": { + "mappings": [ + { + "type": "value", + "options": { + "0": { + "text": "UP", + "color": "green" + }, + "1": { + "text": "TIMEOUT", + "color": "red" + }, + "2": { + "text": "CONN_FAILED", + "color": "red" + }, + "3": { + "text": "READ_FAILED", + "color": "orange" + }, + "4": { + "text": "STRING_MISMATCH", + "color": "orange" + } + } + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "auto", + "textMode": "value", + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto" + } + }, + { + "id": 7, + "title": "当前响应时间", + "type": "stat", + "gridPos": { + "h": 4, + "w": 8, + "x": 8, + "y": 15 + }, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "editorMode": "code", + "expr": "max(net_response_response_time{target=\"$target\"})", + "legendFormat": "latency_s", + "range": true, + "refId": "A" + } + ], + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "orange", + "value": 0.1 + }, + { + "color": "red", + "value": 0.5 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "options": { + "reduceOptions": { + "values": false, + "calcs": [ + "lastNotNull" + ], + "fields": "" + }, + "orientation": "auto", + "textMode": "value_and_name", + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto" + } + }, + { + "id": 8, + "title": "响应时间趋势", + "type": "timeseries", + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 19 + }, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "editorMode": "code", + "expr": "net_response_response_time{target=\"$target\"}", + "legendFormat": "latency_s", + "range": true, + "refId": "A" + } + ], + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "s", + "custom": { + "drawStyle": "line", + "lineInterpolation": "linear", + "lineWidth": 2, + "fillOpacity": 15, + "gradientMode": "none", + "stacking": { + "mode": "none", + "group": "A" + }, + "spanNulls": false, + "showPoints": "auto", + "pointSize": 5 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom", + "calcs": [] + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + } + }, + { + "id": 9, + "title": "状态变化趋势", + "type": "timeseries", + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 19 + }, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "editorMode": "code", + "expr": "net_response_result_code{target=\"$target\"}", + "legendFormat": "result_code", + "range": true, + "refId": "A" + } + ], + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgb(44, 157, 61)", + "value": null + } + ] + }, + "custom": { + "drawStyle": "line", + "lineInterpolation": "smooth", + "lineWidth": 2, + "fillOpacity": 1, + "gradientMode": "none", + "stacking": { + "mode": "none", + "group": "A" + }, + "spanNulls": false, + "showPoints": "auto", + "pointSize": 5 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "hidden", + "placement": "bottom", + "calcs": [] + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + } } ], "refresh": "30s", "schemaVersion": 38, "tags": [ "categraf", - "grafana" + "net_response" ], "templating": { "list": [ @@ -125,6 +632,29 @@ "regex": "", "skipUrlSync": false, "type": "datasource" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "definition": "label_values(net_response_result_code, target)", + "hide": 0, + "includeAll": false, + "label": "target", + "multi": false, + "name": "target", + "options": [], + "query": { + "query": "label_values(net_response_result_code, target)", + "refId": "StandardVariableQuery" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "type": "query" } ] }, @@ -134,7 +664,7 @@ }, "timepicker": {}, "timezone": "browser", - "title": "TCP探测", + "title": "Net Response 探测", "uid": "categraf-net-response-dashboard-ab31c123", "version": 1, "weekStart": ""