perses-lint
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePerses Lint
Perses Lint
Validate Perses resource definitions using . Supports local structural validation and online server-side validation that checks plugin schemas, datasource existence, and variable resolution.
percli lint使用验证Perses资源定义。支持本地结构验证,以及对接服务器的在线验证(可检查插件模式、数据源存在性和变量解析情况)。
percli lintOperator Context
操作场景
This skill operates as a validation gate for Perses resources. It runs against JSON/YAML resource files, interprets errors, applies fixes, and re-validates until all issues are resolved.
percli lint该技能作为Perses资源的验证关卡,针对JSON/YAML资源文件运行,解析错误、应用修复并重新验证,直至所有问题解决。
percli lintHardcoded Behaviors (Always Apply)
硬编码行为(始终生效)
- Show full output: Always display complete lint output, never summarize or truncate
- Online when possible: Prefer mode when a Perses server is reachable
--online - Fix-then-revalidate loop: Never claim fixes are correct without re-running lint
- Report every error: Surface all lint errors, not just the first one encountered
- Preserve user intent: When fixing invalid plugin kinds, ask user which plugin they intended rather than guessing
- 显示完整输出:始终展示完整的lint输出,绝不总结或截断
- 优先在线模式:当可连接到Perses服务器时,优先使用模式
--online - 修复后重新验证循环:未重新运行lint前,绝不声称修复正确
- 报告所有错误:呈现所有lint错误,而非仅第一个遇到的错误
- 保留用户意图:修复无效插件类型时,询问用户期望使用的插件,而非自行猜测
Default Behaviors (ON unless disabled)
默认行为(默认开启,可关闭)
- Batch mode for directories: When pointed at a directory, validate all and
.jsonfiles.yaml - Error grouping: Group lint errors by category (plugin, datasource, variable, layout) in output
- Suggest online mode: If local lint passes but user has a server configured, suggest online re-check
- 目录批量模式:当指定目录时,验证所有和
.json文件.yaml - 错误分组:在输出中按类别(插件、数据源、变量、布局)分组显示lint错误
- 建议在线模式:若本地lint通过,但用户已配置服务器,则建议进行在线重新检查
Optional Behaviors (OFF unless enabled)
可选行为(默认关闭,可开启)
- Auto-fix mode: Automatically apply fixes for unambiguous errors (e.g., typo in plugin kind)
- CI integration: Output lint results in machine-parseable format for CI pipelines
- Strict mode: Treat warnings as errors (fail on any non-clean lint output)
- 自动修复模式:自动修复明确的错误(例如插件类型拼写错误)
- CI集成:以机器可解析的格式输出lint结果,用于CI流水线
- 严格模式:将警告视为错误(任何非干净的lint输出均判定为失败)
What This Skill CAN Do
该技能可实现的功能
- Run local structural validation with
percli lint -f <file> - Run server-side validation with (checks plugin schemas, datasource existence)
percli lint -f <file> --online - Validate individual files or batch-validate entire directories
- Diagnose and fix invalid panel plugin kinds, missing datasource references, broken variable references, and layout mismatches
- Re-validate after fixes to confirm resolution
- 使用进行本地结构验证
percli lint -f <file> - 使用进行服务器端验证(检查插件模式数据源存在性)
percli lint -f <file> --online - 验证单个文件或批量验证整个目录
- 诊断并修复无效面板插件类型、缺失的数据源引用、损坏的变量引用以及布局不匹配问题
- 修复后重新验证以确认问题已解决
What This Skill CANNOT Do
该技能无法实现的功能
- Create dashboards from scratch (use perses-dashboard-create)
- Deploy or configure Perses servers (use perses-deploy)
- Develop or test custom plugins (use perses-plugin-create or perses-plugin-test)
- Fix PromQL/TraceQL query logic errors (lint validates structure, not query semantics)
- 从零开始创建仪表盘(请使用perses-dashboard-create)
- 部署或配置Perses服务器(请使用perses-deploy)
- 开发或测试自定义插件(请使用perses-plugin-create或perses-plugin-test)
- 修复PromQL/TraceQL查询逻辑错误(lint仅验证结构,不涉及查询语义)
Error Handling
错误处理
| Cause | Symptom | Solution |
|---|---|---|
| Invalid panel plugin kind | | Check against official list below. Common typos: |
| Missing datasource reference | | Add the datasource to the dashboard's |
| Invalid variable reference | | Check all |
| Layout $ref mismatch | | Ensure every panel ID referenced in layout sections exists as a key in |
| Connection refused (online mode) | | Perses server is not running or URL is wrong. Verify server is up with |
| Authentication failure (online mode) | | Login first with |
| 原因 | 症状 | 解决方案 |
|---|---|---|
| 无效面板插件类型 | | 对照下方官方列表检查。常见拼写错误: |
| 缺失数据源引用 | | 将数据源添加到仪表盘的 |
| 无效变量引用 | | 检查所有 |
| 布局$ref不匹配 | | 确保布局部分引用的每个面板ID在 |
| 连接被拒绝(在线模式) | 使用 | Perses服务器未运行或URL错误。使用 |
| 认证失败(在线模式) | 使用 | 先使用 |
Official Plugin Kinds (27 total)
官方插件类型(共27种)
Chart plugins: TimeSeriesChart, BarChart, GaugeChart, HeatmapChart, HistogramChart, PieChart, ScatterChart, StatChart, StatusHistoryChart, FlameChart
Table plugins: Table, TimeSeriesTable, LogsTable, TraceTable
Display plugins: Markdown, TracingGanttChart
Variable plugins: DatasourceVariable, StaticListVariable
Datasource plugins: PrometheusDatasource, TempoDatasource, and additional community datasource types
图表插件:TimeSeriesChart、BarChart、GaugeChart、HeatmapChart、HistogramChart、PieChart、ScatterChart、StatChart、StatusHistoryChart、FlameChart
表格插件:Table、TimeSeriesTable、LogsTable、TraceTable
展示插件:Markdown、TracingGanttChart
变量插件:DatasourceVariable、StaticListVariable
数据源插件:PrometheusDatasource、TempoDatasource,以及其他社区数据源类型
Anti-Patterns
反模式
| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
Running | Applies a broken resource to the server, then you discover errors at runtime or in the UI | Always run |
| Only validating locally when a server is available | Local lint checks structure only. Online mode validates against actual plugin schemas, existing datasources, and variable resolution. Many errors only surface with | Use |
| Ignoring lint warnings (only fixing errors) | Warnings often indicate deprecated fields, unused variables, or schema drift that will become errors in future Perses versions | Fix all warnings. Use strict mode ( |
| Fixing one error at a time and re-running | Wastes cycles. Multiple errors are often related (e.g., renamed datasource breaks 5 panels) | Read ALL lint errors first, identify root causes, batch-fix related errors, then re-validate once. |
| 反模式 | 失败原因 | 正确做法 |
|---|---|---|
先运行 | 向服务器应用了有问题的资源,之后才在运行时或UI中发现错误 | 运行 |
| 已有服务器可用时仅进行本地验证 | 本地lint仅检查结构。在线模式会针对实际插件模式、已存在的数据源和变量解析进行验证。许多错误只有在 | 只要可连接到Perses服务器,就使用 |
| 忽略lint警告(仅修复错误) | 警告通常表示已废弃字段、未使用变量或模式偏移,这些在未来Perses版本中可能会变成错误 | 修复所有警告。在CI中使用严格模式(若可用 |
| 一次修复一个错误并重新运行lint | 浪费时间。多个错误往往相关(例如重命名数据源导致5个面板失效) | 先阅读所有lint错误,找出根本原因,批量修复相关错误,然后仅重新验证一次。 |
Anti-Rationalization
反合理化借口
| Rationalization | Reality | Required Action |
|---|---|---|
| "Lint passed locally, so the dashboard is correct" | Local lint only checks structure. Plugin schemas, datasource existence, and variable resolution require online mode. | Run |
| "I fixed the error, no need to re-run lint" | Fixes can introduce new errors (e.g., fixing a panel kind may reveal a previously-masked datasource error) | Always re-run |
| "That warning is not important" | Warnings in Perses often indicate fields that will be removed or required in the next version. Ignoring them creates upgrade debt. | Fix warnings now. They cost minutes today and hours during upgrades. |
| 合理化借口 | 实际情况 | 必要操作 |
|---|---|---|
| 本地lint通过了,所以仪表盘没问题 | 本地lint仅检查结构。插件模式、数据源存在性和变量解析需要在线模式验证。 | 在声明资源有效前,务必针对服务器运行 |
| 我已经修复了错误,不需要重新运行lint | 修复可能引入新错误(例如修复面板类型可能暴露之前被掩盖的数据源错误) | 每次修复后务必重新运行 |
| 那个警告不重要 | Perses中的警告通常表示字段将在后续版本中被移除或设为必填。忽略它们会增加升级成本。 | 立即修复警告。现在修复只需几分钟,升级时可能需要数小时。 |
FORBIDDEN Patterns
禁止模式
- NEVER mark lint as passing when there are unresolved errors or warnings
- NEVER modify output to hide errors from the user
percli - NEVER skip re-validation after applying fixes
- NEVER guess a plugin kind without checking the official 27-plugin list
- NEVER run as a substitute for
percli apply("it will tell us if it fails")percli lint
- 绝对不要在存在未解决的错误或警告时标记lint通过
- 绝对不要修改输出以向用户隐藏错误
percli - 绝对不要在应用修复后跳过重新验证
- 绝对不要未对照官方27种插件列表就猜测插件类型
- 绝对不要用替代
percli apply(“失败了它会告诉我们”)percli lint
Blocker Criteria
阻塞条件
Do NOT proceed past validation if any of these are true:
- reports any errors (warnings in strict mode)
percli lint - Online validation was requested but the server is unreachable and no fallback was acknowledged
- A plugin kind is used that is not in the official 27-plugin list and the user has not confirmed it is a custom plugin
- Any in the layout or variables section points to a non-existent target
$ref
若出现以下任一情况,请勿继续验证:
- 报告任何错误(严格模式下包括警告)
percli lint - 已请求在线验证,但服务器不可达且未确认回退方案
- 使用了不在官方27种插件列表中的插件类型,且用户未确认它是自定义插件
- 布局或变量部分的任何指向不存在的目标
$ref
Instructions
操作步骤
Phase 1: VALIDATE
阶段1:验证
Goal: Run lint and capture all errors.
bash
undefined目标:运行lint并捕获所有错误。
bash
undefinedLocal validation (structural checks only)
本地验证(仅结构检查)
percli lint -f <file>
percli lint -f <file>
Online validation (includes plugin schema checks, datasource existence)
在线验证(包括插件模式检查、数据源存在性)
percli lint -f <file> --online
percli lint -f <file> --online
Batch validation — all JSON files in current directory
批量验证 — 当前目录下所有JSON文件
for f in *.json; do percli lint -f "$f"; done
for f in *.json; do percli lint -f "$f"; done
Batch validation — all YAML files
批量验证 — 所有YAML文件
for f in *.yaml; do percli lint -f "$f"; done
If online mode fails with connection errors, fall back to local mode and note the limitation.
**Gate**: All lint output captured. Proceed to Phase 2.for f in *.yaml; do percli lint -f "$f"; done
若在线模式因连接错误失败,回退到本地模式并记录限制。
**关卡**:已捕获所有lint输出。进入阶段2。Phase 2: FIX
阶段2:修复
Goal: Resolve every reported error.
For each error, identify the root cause and apply the fix:
- Invalid panel plugin kind -- Check the field against the 27 official plugins listed above. Correct typos or capitalization.
kind - Missing datasource reference -- Add the missing datasource to or fix the name to match an existing datasource.
spec.datasources - Invalid variable reference -- Verify values match keys in
$ref. Fix typos or add missing variable definitions.spec.variables - Layout $ref mismatch -- Ensure every panel ID in has a corresponding entry in
spec.layouts[].spec.display.panels.spec.panels - Unknown field errors -- Check Perses API version. Field may have been renamed or removed in a newer version.
When multiple errors share a root cause (e.g., a renamed datasource), fix the root cause once rather than patching each symptom individually.
Gate: All identified errors addressed. Proceed to Phase 3.
目标:解决所有报告的错误。
针对每个错误,找出根本原因并应用修复:
- 无效面板插件类型 — 对照上方列出的27种官方插件检查字段。修正拼写错误或大小写。
kind - 缺失数据源引用 — 将缺失的数据源添加到中,或修正名称以匹配已存在的数据源。
spec.datasources - 无效变量引用 — 验证值是否与
$ref中的键匹配。修复拼写错误或添加缺失的变量定义。spec.variables - 布局$ref不匹配 — 确保中的每个面板ID在
spec.layouts[].spec.display.panels中都有对应条目。spec.panels - 未知字段错误 — 检查Perses API版本。该字段可能在新版本中被重命名或移除。
当多个错误共享同一根本原因(例如重命名数据源),只需修复一次根本原因,而非逐个修补症状。
关卡:所有已识别的错误均已处理。进入阶段3。
Phase 3: RE-VALIDATE
阶段3:重新验证
Goal: Confirm all fixes are correct.
bash
undefined目标:确认所有修复正确。
bash
undefinedRe-run the same lint command used in Phase 1
重新运行阶段1中使用的lint命令
percli lint -f <file>
percli lint -f <file>
or
或
percli lint -f <file> --online
- If new errors appear, return to Phase 2.
- Maximum 3 fix-revalidate cycles. If errors persist after 3 cycles, report remaining errors to the user with full context.
**Gate**: Lint returns zero errors. Validation complete.
---percli lint -f <file> --online
- 若出现新错误,返回阶段2。
- 最多进行3次修复-重新验证循环。若3次循环后仍有错误,向用户报告剩余错误及完整上下文。
**关卡**:Lint返回零错误。验证完成。
---References
参考资料
- Perses documentation: https://perses.dev/docs/
- percli CLI reference: https://perses.dev/docs/cli/percli/
- Perses plugin list: https://perses.dev/docs/plugins/
- Perses GitHub repository: https://github.com/perses/perses
- percli lint usage:
percli lint --help
- Perses文档:https://perses.dev/docs/
- percli CLI参考:https://perses.dev/docs/cli/percli/
- Perses插件列表:https://perses.dev/docs/plugins/
- Perses GitHub仓库:https://github.com/perses/perses
- percli lint使用说明:
percli lint --help