Loading...
Loading...
Compare original and translation side by side
percli lint.dashboard.dashboardpercli migratepercliStaticListVariablepercli lint.dashboard.dashboardpercli migratepercliStaticListVariablepercli migrate --onlinepercli lintpercli migrate --onlinepercli lint--format crpercli apply --dry-run--format crpercli apply --dry-run| Cause | Symptom | Solution |
|---|---|---|
| Invalid Grafana JSON format | | Verify JSON is valid with |
| Grafana version < 9.0.0 | | Upgrade Grafana to 9.0.0+ before export, or manually update the dashboard JSON |
| Unsupported plugin warning | Migration succeeds but panels contain | Document each unsupported panel, then manually replace with the closest Perses equivalent (TimeSeriesChart, StatChart, Table, or Markdown panel) |
| Online mode connection failure | | Verify Perses server URL and port, check authentication (run |
| Panel layout lost in migration | Grafana grid coordinates don't map cleanly to Perses Grid layout — panels overlap or have wrong sizes | After migration, review the |
| Missing datasource references | Migrated dashboard references datasource names that don't exist in Perses | Create matching Perses datasources before deploying, or update the migrated JSON to reference existing Perses datasource names |
| 原因 | 症状 | 解决方案 |
|---|---|---|
| 无效的Grafana JSON格式 | | 使用 |
| Grafana版本低于9.0.0 | | 迁移前将Grafana升级到9.0.0+,或手动更新仪表板JSON的 |
| 不支持插件警告 | 迁移成功,但面板包含值为 | 记录每个不支持的面板,然后手动替换为最接近的Perses等效面板(TimeSeriesChart、StatChart、Table或Markdown面板) |
| 在线模式连接失败 | | 验证Perses服务器的URL和端口,检查认证信息(先运行 |
| 迁移后面板布局丢失 | Grafana的网格坐标无法完美映射到Perses的Grid布局——面板重叠或尺寸错误 | 迁移后,检查 |
| 缺失数据源引用 | 迁移后的仪表板引用了Perses中不存在的数据源名称 | 部署前创建匹配的Perses数据源,或更新迁移后的JSON以引用已存在的Perses数据源名称 |
| Anti-Pattern | Why It's Wrong | Do Instead |
|---|---|---|
| Deploying migrated dashboards without reviewing StaticListVariable placeholders | Users see broken panels with placeholder values, lose trust in the migration | Search all migrated files for |
| Running migration in offline mode when online mode is available | Offline mode uses bundled plugin migration logic which may be outdated — misses latest panel type mappings | Always prefer |
| Deleting original Grafana JSON files after migration | No rollback path if migration output is wrong, no way to re-run with updated | Keep originals in a |
| Batch migrating everything at once without prioritization | Critical dashboards get the same attention as abandoned test dashboards, errors pile up | Prioritize by usage: migrate the top 5-10 most-viewed dashboards first, validate thoroughly, then batch the rest |
| Migrating dashboards without first checking Grafana version | Wasted effort — older Grafana JSON schemas produce broken or empty Perses output | Run |
| 反模式 | 问题所在 | 正确做法 |
|---|---|---|
| 未检查StaticListVariable占位符就部署迁移后的仪表板 | 用户会看到包含占位符的损坏面板,失去对迁移结果的信任 | 在所有迁移文件中搜索 |
| 在线模式可用时仍使用离线模式 | 离线模式使用的插件迁移逻辑是快照版本,可能滞后数周或数月——服务器端会持续添加新的面板类型映射 | 只要Perses服务器可用,就优先使用在线模式;离线模式仅作为 fallback |
| 迁移后删除Grafana原始JSON文件 | 若迁移输出存在问题,将没有回滚路径,重新迁移的成本极高 | 将原始文件保存在 |
| 不做优先级区分,一次性批量迁移所有仪表板 | 关键仪表板与废弃的测试仪表板得到相同的关注,错误堆积 | 按使用频率排序:先迁移前5-10个最常访问的仪表板,彻底验证后再批量迁移其余的 |
| 迁移前未检查Grafana版本 | 白费力气——旧版Grafana JSON架构会生成损坏或空的Perses输出 | 迁移前运行 |
| Rationalization | Reality | Required Action |
|---|---|---|
| "The migration completed without errors so it's correct" | | Diff panel counts: compare number of panels in Grafana source vs Perses output, search for all placeholder values |
| "Online mode isn't necessary, offline is fine" | Offline mode bundles a snapshot of plugin migration logic that may be weeks or months behind — new panel type mappings are added to the server continuously | Use online mode whenever a Perses server is available, verify server version is current |
| "We can fix the placeholders later after deployment" | Users will see broken dashboards immediately, file bugs, lose confidence in the migration — fixing in production is always harder than fixing before deploy | Fix or document every placeholder before deploying, even if it delays the migration timeline |
| "The layout looks close enough" | Grafana's 24-column grid and Perses's Grid layout have different coordinate systems — "close enough" means overlapping panels or wasted whitespace that makes dashboards unusable | Visually verify every migrated dashboard in the Perses UI before declaring migration complete |
| 合理化借口 | 实际情况 | 必要操作 |
|---|---|---|
| “迁移完成且无错误,所以结果是正确的” | 即使面板被替换为StaticListVariable占位符, | 对比面板数量:比较Grafana源面板数与Perses输出面板数,搜索所有占位符值 |
| “在线模式没必要,离线模式就够了” | 离线模式打包的插件迁移逻辑可能滞后数周或数月——服务器端会持续添加新的面板类型映射 | 尽可能使用在线模式,并验证服务器版本为最新 |
| “我们可以部署后再修复占位符” | 用户会立即看到损坏的仪表板,提交bug,失去对迁移的信任——生产环境中修复比部署前修复难得多 | 部署前修复或记录每个占位符,即使这会推迟迁移时间 |
| “布局看起来差不多就行” | Grafana的24列网格与Perses的Grid布局使用不同的坐标系统——“差不多”意味着面板重叠或留白过多,导致仪表板无法使用 | 视觉验证每个迁移后的仪表板在Perses UI中的显示效果,确认迁移完成 |
percli migrate.dashboardpercli migratepercli lintpercli migrate.dashboardpercli migratepercli lintcurl -s https://grafana.example.com/api/health | jq '.version'curl -s https://grafana.example.com/api/health | jq '.version'
Export a single dashboard:
```bash
导出单个仪表板:
```bash
For bulk export, iterate over all dashboards:
```bash
curl -H "Authorization: Bearer <token>" \
https://grafana.example.com/api/search?type=dash-db \
| jq -r '.[].uid' | while read uid; do
curl -s -H "Authorization: Bearer <token>" \
"https://grafana.example.com/api/dashboards/uid/$uid" \
| jq '.dashboard' > "grafana-$uid.json"
done.dashboard
批量导出所有仪表板:
```bash
curl -H "Authorization: Bearer <token>" \
https://grafana.example.com/api/search?type=dash-db \
| jq -r '.[].uid' | while read uid; do
curl -s -H "Authorization: Bearer <token>" \
"https://grafana.example.com/api/dashboards/uid/$uid" \
| jq '.dashboard' > "grafana-$uid.json"
done.dashboardundefinedundefined
**Migration notes**:
- Requires Perses server connection for online mode (uses latest plugin migration logic)
- Compatible with Grafana 9.0.0+, latest version recommended
- Unsupported variables become `StaticListVariable` with values `["grafana", "migration", "not", "supported"]`
- Panel type mapping: Graph to TimeSeriesChart, Stat to StatChart, Table to Table
- Panels with no Perses equivalent need manual replacement after migration
**Gate**: Conversion complete. All files produced without errors. Proceed to Phase 3.
**迁移注意事项**:
- 在线模式需要连接到Perses服务器(使用最新的插件迁移逻辑)
- 仅兼容Grafana 9.0.0+,推荐使用最新版本
- 不支持的变量会被替换为值为`["grafana", "migration", "not", "supported"]`的`StaticListVariable`
- 面板类型映射:Graph → TimeSeriesChart,Stat → StatChart,Table → Table
- 无Perses等效面板的组件需要在迁移后手动替换
**检查点**:转换完成,所有文件生成无错误。进入阶段3。undefinedundefined
Check for:
- Panel types that weren't converted (search for StaticListVariable placeholders)
- Missing datasource references
- Variable references that didn't translate
- Layout issues (overlapping or mis-sized panels in Grid layout)
**Gate**: Validation passes. All StaticListVariable placeholders documented with remediation plan. Proceed to Phase 4.
检查内容:
- 未被转换的面板类型(搜索StaticListVariable占位符)
- 缺失的数据源引用
- 未被正确转换的变量引用
- 布局问题(Grid布局中面板重叠或尺寸错误)
**检查点**:验证通过,所有StaticListVariable占位符已记录并制定修复计划。进入阶段4。undefinedundefined
Verify migration:
```bash
percli get dashboard --project <project>
验证迁移结果:
```bash
percli get dashboard --project <project>| Resource | URL |
|---|---|
| Perses GitHub | https://github.com/perses/perses |
| percli documentation | https://perses.dev/docs/tooling/percli/ |
| Grafana API — Get Dashboard | https://grafana.com/docs/grafana/latest/developers/http_api/dashboard/#get-dashboard-by-uid |
| Grafana API — Search | https://grafana.com/docs/grafana/latest/developers/http_api/dashboard/#dashboard-search |
| Perses Plugin System | https://perses.dev/docs/plugins/ |
| Migration Guide | https://perses.dev/docs/tooling/percli/#migrate |