
MySQL Overview 面板报错修复记录(stat 插件缺失)
适用环境:node2 (192.168.56.132)・Grafana 6.0.1
整理日期:2026-10-10
文档性质:MySQL Overview (Full) 面板报Panel plugin with id stat could not be found的问题原因与修复过程
1. 问题现象
打开 MySQL Overview (Full) 面板,Overview 分栏 6 张卡片(MySQL Up / Uptime / Running Threads / Threads Connected / Max Used Connections / Aborted Clients)全部显示红色报错:
Panel plugin with id stat could not be found
其余分栏(Connections / Queries / InnoDB / Network & Cache)的折线图正常。
2. 问题根因
Grafana 6.0.1 不支持 stat 面板类型。
stat(新式单值面板)是 Grafana 7.x 才引入的插件。- 我用
POST /api/dashboards/db创建面板时,Overview 分栏用了type: "stat"。 - Grafana 6.0.1 找不到
stat插件 → 报Panel plugin with id stat could not be found,卡片无法渲染。
这是本次会话里 PG 主从面板、MySQL Overview 面板共用的同一坑:凡 Overview 用
stat都会报错。Grafana 6.x 应使用singlestat(旧式单值面板)或graph。
3. 修复过程
3.1 确认受影响的面板(type=stat)
curl -s -u admin:Lihj2026 http://127.0.0.1:3000/api/dashboards/uid/cninLfrvk \
| python3 -c "import sys,json;d=json.load(sys.stdin);[print(p.get('id'),p.get('title'),'|',p.get('type')) for p in d['dashboard']['panels']]"
命中 6 个 stat:id 1~6(MySQL Up / Uptime / Running Threads / Threads Connected / Max Used Connections / Aborted Clients)。
3.2 修改:stat → singlestat(并适配字段)
把 6 个面板的 type 改为 singlestat,删除仅 stat 支持的字段,补充 singlestat 字段:
p['type']='singlestat'
p.pop('fieldConfig',None); p.pop('options',None) # stat 特有
p['format']='none' # 显示原值
p['sparkline']={'show':False}
p['valueName']='current' # 显示当前值
p['gauge']={'show':False}
p['colorValue']=False
p['valueMaps']=[{'value':'null','op':'='}]
p['rangeMaps']=[]; p['mappingType']=1
3.3 回写面板(POST /api/dashboards/db)
curl -s -u admin:Lihj2026 -X POST http://127.0.0.1:3000/api/dashboards/db \
-H "Content-Type: application/json" \
-d '{"dashboard":<修改后的dashboard>,"folderId":0,"overwrite":true}'
面板更新到 version 3。
3.4 验证
- 类型确认:Overview 6 个全部变为
singlestat,无残留stat。
MySQL Up = singlestat
Uptime (days) = singlestat
Running Threads = singlestat
Threads Connected = singlestat
Max Used Connections = singlestat
Aborted Clients = singlestat
- 数据取数:6 个查询逐个验证均 OK(1),无空图。
mysql_up | OK(1)
mysql_global_status_uptime/86400 | OK(1)
mysql_global_status_threads_running | OK(1)
mysql_global_status_threads_connected | OK(1)
mysql_global_status_max_used_connections | OK(1)
mysql_global_status_aborted_clients | OK(1)
4. 通用经验(避免同类问题)
| 场景 | 正确面板类型 |
|---|---|
| Grafana 6.x 单值卡片 | singlestat(不要用 stat) |
| Grafana 6.x 折线/面积 | graph |
| Grafana 7.x+ | stat / timeseries / table |
排查命令:curl -u admin:Lihj2026 http://127.0.0.1:3000/api/dashboards/uid/<uid> | grep '"type"'
同类问题已处理:PostgreSQL Replication (主从监控) 面板 Overview 也曾用
stat报错,同样改为singlestat解决(见 PG 主从文档)。
5. 受影响面板清单(本次会话)
| 面板 | uid | 已处理 |
|---|---|---|
| MySQL Overview (Full) | cninLfrvk | ✅ stat→singlestat(version 3) |
| PostgreSQL Replication (主从监控) | Ui74yfrDk | ✅ stat→singlestat(version 3) |
| MySQL Monitoring(精简) | H2Xa-frDk | 原本未用 stat,无此问题 |
本文档记录 2026-10-10 修复 MySQL Overview 面板 stat 插件缺失报错的完整过程,命令均经实际执行验证。
浙公网安备 33010602011771号