cargo-observability
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCargo CLI — Observability
Cargo CLI — 可观测性
Alerts. An alert is a scheduled threshold check. On every cron tick it measures a scope (what to watch), compares the measured value against a threshold (the breach condition), and on breach fires actions — each as its own run — and records an event. This is the proactive counterpart to : diagnostics explains a failure after you notice it; an alert tells you the moment a metric crosses a line.
cargo-diagnosticsEverything lives under one CLI domain:
bash
cargo-ai observability alert … # the alert CRUD + preview surface
cargo-ai observability event … # an alert's firing history告警。告警是一种定时阈值检查机制。每次cron触发时,它会测量一个监控范围(要监控的对象),将测量值与阈值(触发条件)进行比较,当超出阈值时会触发动作——每个动作都会独立运行,并记录一个事件。这是的主动式补充:诊断功能是在你发现故障后解释原因;而告警会在指标超出阈值的瞬间主动通知你。
cargo-diagnostics所有功能都位于一个CLI域下:
bash
cargo-ai observability alert … # 告警的增删改查 + 预览界面
cargo-ai observability event … # 告警的触发历史The three moving parts of every alert
每个告警的三个核心组件
| Part | Flag | What it is |
|---|---|---|
| Scope | | What to measure — one of six sources: |
| Threshold | | When it breaches — a |
| Actions | | What happens on breach — an |
The scope and threshold are a matched pair — a metric can only be computed over the scopes that produce it (e.g. needs telemetry, needs a model). The full compatibility matrix, every metric's meaning and units, and every scope filter field are in — read it before writing a / pair you haven't used before.
errorRatefreshnessreferences/scopes-and-thresholds.md--scope--threshold| 组件 | 标识 | 说明 |
|---|---|---|
| 监控范围 | | 要测量的对象——六种来源之一: |
| 阈值 | | 触发条件——包含 |
| 动作 | | 触发后的操作——一个 |
监控范围和阈值是匹配对——一个指标只能在能生成它的监控范围内计算(例如需要遥测数据,需要模型)。完整的兼容性矩阵、每个指标的含义和单位、每个监控范围的过滤字段都记录在****中——在编写未使用过的/组合前,请先阅读该文档。
errorRatefreshnessreferences/scopes-and-thresholds.md--scope--thresholdThe golden rule: preview
before you create
previewcreate黄金准则:创建前先预览
alert previewbash
cargo-ai observability alert preview \
--scope '{"kind":"runs","workflowUuid":"<uuid>","statuses":["error"]}' \
--threshold '{"metric":"errorRate","operator":"gte","value":10}' \
--window-minutes 1440 # last 24h; default 60- →
outcome: "computed". Set your threshold from{ value, total, failed, isBreached }.value - → the window had nothing to measure (see the empty-vs-zero rule in
outcome: "empty").references/alert-lifecycle.md - →
outcome: "notComputed". A bad SQL query, a deleted model, or an invalid scope/threshold pairing all land here — fix it before creating.{ errorMessage }
--window-minutesspansrunsrecordsmodelAlways preview first. It is free, it is the only way to size a threshold correctly, and it catches an invalid pairing before it becomes a schedule that writes an event every tick.
erroralert previewbash
cargo-ai observability alert preview \
--scope '{"kind":"runs","workflowUuid":"<uuid>","statuses":["error"]}' \
--threshold '{"metric":"errorRate","operator":"gte","value":10}' \
--window-minutes 1440 # 最近24小时;默认60分钟- → 返回
outcome: "computed"。根据{ value, total, failed, isBreached }设置你的阈值。value - → 监控窗口内没有可测量的数据(请查看
outcome: "empty"中的空窗口与零值规则)。references/alert-lifecycle.md - → 返回
outcome: "notComputed"。可能是SQL查询错误、模型已删除,或监控范围/阈值组合无效——创建前请修复该问题。{ errorMessage }
--window-minutesspansrunsrecordsmodel务必先预览。预览是免费的,是正确设置阈值的唯一方法,还能在定时任务每次触发都写入事件之前发现无效的组合。
errorCommands
命令
All commands output JSON. Reads need a token with ; create/update/remove need (an admin token has both; a plain member token may not — see Prerequisites).
observability:readobservability:write所有命令均输出JSON。读取操作需要拥有权限的令牌;创建/更新/删除操作需要权限(管理员令牌拥有这两种权限;普通成员令牌可能没有——请查看前提条件)。
observability:readobservability:writeCreate an alert
创建告警
bash
cargo-ai observability alert create \
--name "CRM sync error rate" \
--description "Page when the HubSpot sync starts failing" \
--cron "*/30 * * * *" \
--scope '{"kind":"runs","workflowUuid":"<workflow-uuid>","statuses":["error"]}' \
--threshold '{"metric":"errorRate","operator":"gte","value":10}' \
--actions '[{"kind":"agent","agentUuid":"<agent-uuid>","config":{"message":"{{alert.name}} breached: {{event.value}}% errors. {{alert.url}}"}}]'- — 5-field cron or
--cron(e.g.@every <interval>), always UTC, at most once a minute. The UI presets bottom out at 30 minutes; go tighter only with reason (every tick scans ClickHouse and can fire paid runs).@every 30m - — create it paused (evaluate nothing until you
--disabled).update --enabled true - — file it under a folder (from
--folder <uuid>).cargo-workspace-management - — optional. Omit for a silent alert. The config is templated against the firing context (
--actions,{{alert.*}}) — see{{event.*}}for the full variable list. Each action's target (references/alert-lifecycle.md/agentUuid/toolUuid) is validated to exist in the workspace at create time.connectorUuid
bash
cargo-ai observability alert create \
--name "CRM同步错误率" \
--description "当HubSpot同步开始失败时发送页面告警" \
--cron "*/30 * * * *" \
--scope '{"kind":"runs","workflowUuid":"<workflow-uuid>","statuses":["error"]}' \
--threshold '{"metric":"errorRate","operator":"gte","value":10}' \
--actions '[{"kind":"agent","agentUuid":"<agent-uuid>","config":{"message":"{{alert.name}}触发告警:{{event.value}}% 错误率。{{alert.url}}"}}]'- — 5字段cron表达式 或
--cron(例如@every <interval>),始终使用UTC时区,触发频率最高为每分钟一次。UI预设的最小间隔为30分钟;只有在必要时才设置更短的间隔(每次触发都会扫描ClickHouse,可能会触发付费运行)。@every 30m - — 创建时处于暂停状态(直到执行
--disabled才会开始评估)。update --enabled true - — 将告警归类到指定文件夹(来自
--folder <uuid>)。cargo-workspace-management - — 可选。省略则为静默告警。配置内容可使用触发上下文进行模板化(
--actions、{{alert.*}})——完整的变量列表请查看{{event.*}}。创建时会验证每个动作的目标(references/alert-lifecycle.md/agentUuid/toolUuid)是否存在于工作区中。connectorUuid
List, get, update, remove
列出、查询、更新、删除
bash
cargo-ai observability alert list # all alerts, each with its lastEvent
cargo-ai observability alert get <uuid> # one alert + its lastEvent
cargo-ai observability alert update --uuid <uuid> \
--enabled false # pause it (true/false — must be literal)
cargo-ai observability alert update --uuid <uuid> \
--threshold '{"metric":"errorRate","operator":"gte","value":20}' # raise the bar
cargo-ai observability alert update --uuid <uuid> \
--description none # "none" clears; --folder none unfiles
cargo-ai observability alert remove <uuid>--enabledtruefalse--enabled yesupdate--description none--folder nonebash
cargo-ai observability alert list # 所有告警,包含各自的最新事件
cargo-ai observability alert get <uuid> # 查询单个告警 + 其最新事件
cargo-ai observability alert update --uuid <uuid> \
--enabled false # 暂停告警(值必须是字面量true/false)
cargo-ai observability alert update --uuid <uuid> \
--threshold '{"metric":"errorRate","operator":"gte","value":20}' # 提高阈值
cargo-ai observability alert update --uuid <uuid> \
--description none # "none"表示清除描述;--folder none表示移出文件夹
cargo-ai observability alert remove <uuid>--enabledtruefalse--enabled yesupdate--description none--folder noneInspect firing history
查看触发历史
bash
cargo-ai observability event list <alertUuid> # latest evaluation events, newest firstEach event carries ( / / ), the measured , a snapshot of the // as they were when it fired (the alert can change afterwards), (the runs the actions spawned — feed these to or ), the evaluation window, and for events. = breached and fired; = the metric could not be computed.
statushealthyunhealthyerrorvaluescopethresholdactionsrunUuidscargo-diagnosticsorchestration run geterrorMessageerrorunhealthyerrorbash
cargo-ai observability event list <alertUuid> # 最新的评估事件,按时间倒序排列每个事件包含(//)、测量的、触发时//的快照(告警后续可能会更改)、(动作触发的运行实例——可将其传入或)、评估窗口,以及事件对应的。表示超出阈值并触发了动作;表示无法计算指标。
statushealthyunhealthyerrorvaluescopethresholdactionsrunUuidscargo-diagnosticsorchestration run geterrorerrorMessageunhealthyerrorHow evaluation actually works
评估的实际工作原理
The lifecycle — cron windows and the ClickHouse indexing lag, the at-most-once firing guarantee (an alert never re-fires on the same rows; a sustained breach is re-detected on the next tick), the empty-window-vs-real-zero rule that makes a dead-man's switch, and the full / templating context — is documented in . Read it before you rely on an alert for anything time-sensitive.
lte{{alert.*}}{{event.*}}references/alert-lifecycle.md生命周期——cron窗口和ClickHouse索引延迟、最多触发一次的保证(告警不会针对同一数据重复触发;持续超出阈值会在下次触发时被重新检测)、区分空窗口与实际零值的规则(该规则使可作为心跳检测开关),以及完整的/模板上下文——均记录在****中。在依赖告警处理时间敏感的任务前,请先阅读该文档。
lte{{alert.*}}{{event.*}}references/alert-lifecycle.mdWorked recipes
实战示例
references/examples/recipes.mdcount lte 0references/examples/recipes.mdcount lte 0Declarative alternative: defineAlert
(CDK)
defineAlert声明式替代方案:defineAlert
(CDK)
defineAlertThis skill is the imperative surface — one-off calls. To manage an alert as code (in git, reproducible, deployed alongside the workflow it watches), use CDK's builder instead — see and "Declarative vs imperative" in the router. Same scope/threshold/action model; different authoring mode.
cargo-ai observability alert …defineAlert../cargo-cdk/SKILL.md本技能是命令式操作界面——通过单次调用完成操作。若要以代码形式管理告警(存储在git中、可重现、与所监控的工作流一同部署),请使用CDK的构建器——详情请查看以及路由中的“声明式与命令式对比”。两者使用相同的监控范围/阈值/动作模型;只是创作方式不同。
cargo-ai observability alert …defineAlert../cargo-cdk/SKILL.mdCost discipline
成本管控
An alert's actions fire as real runs — if an action calls a paid connector action or an agent, every breach re-bills. A poorly-sized threshold on a tight cron can breach (and bill) every tick. Two safeguards:
- Preview to size the threshold so it fires on genuine anomalies, not normal variance.
- If an action node calls a credits-based provider action, treat it like any scheduled paid workflow: read that provider's playbook (esp. its Recurring use section) in , and apply the spend rules in
../cargo-gtm/provider-playbooks/. Prefer cheap notification actions (an agent that posts to Slack, a connector notification) over anything that fans out.../cargo-gtm/references/cost-discipline.md
告警的动作会作为真实运行实例触发——如果动作调用了付费连接器或Agent,每次触发都会重新计费。阈值设置不当且cron间隔过短的告警可能会每次触发都超出阈值(并产生费用)。有两项防护措施:
- 通过预览校准阈值,使其仅在出现真正异常时触发,而非正常波动。
- 如果动作节点调用了基于信用额度的提供商动作,请将其视为定时付费工作流:阅读中该提供商的操作手册(尤其是重复使用部分),并遵循
../cargo-gtm/provider-playbooks/中的支出规则。优先选择低成本的通知动作(例如发送到Slack的Agent、连接器通知),而非会产生分支的操作。../cargo-gtm/references/cost-discipline.md
Prerequisites
前提条件
See for install, login ( / ), JSON conventions, and error shapes. Verify with first.
../cargo/references/prerequisites.md--oauth--tokencargo-ai whoamiAlerts are guarded by / permissions. If a create/update/remove returns a permission error, the token lacks — use an admin token or have one granted ().
observability:readobservability:writeobservability:writecargo-workspace-management安装、登录(/)、JSON约定和错误格式请查看。请先使用验证。
--oauth--token../cargo/references/prerequisites.mdcargo-ai whoami告警受/权限保护。如果创建/更新/删除操作返回权限错误,说明令牌缺少权限——请使用管理员令牌或申请该权限(通过)。
observability:readobservability:writeobservability:writecargo-workspace-managementWhen the CLI surprises you
当CLI出现异常时
If a documented flag, scope field, or response shape doesn't match what you observe (a fix may have shipped, or the docs may have drifted), re-refresh the CLI and skills; if it still doesn't add up, file a report — it's read by the team:
bash
cargo-ai workspaceManagement report create \
--title "<one-line summary>" \
--description "<exact command(s), errorMessage verbatim, expected vs actual, UUIDs>"如果文档中记录的标识、监控范围字段或响应格式与实际不符(可能已发布修复,或文档已过时),请重新刷新CLI和技能;若问题仍存在,请提交报告——团队会查看报告:
bash
cargo-ai workspaceManagement report create \
--title "<一行摘要>" \
--description "<准确的命令、错误信息原文、预期与实际情况、UUID>"Presenting results
结果展示
Follow : lead with the outcome ("alert created, will page the on-call agent when the CRM sync's error rate hits 10% over 30 min"), summarize an alert or its events as a compact table, never dump raw / JSON into the conversation.
../cargo/references/interaction.mdalert getevent list请遵循:先说明结果(“告警已创建,当CRM同步的错误率在30分钟内达到10%时,会向值班Agent发送页面告警”),将告警或其事件总结为简洁的表格,切勿将原始的/ JSON直接粘贴到对话中。
../cargo/references/interaction.mdalert getevent list