oodle-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOodle CLI — Core Usage
Oodle CLI — 核心使用方法
This skill teaches the agent to invoke the CLI safely, with the right flags, time formats, and authentication for any subcommand.
oodle本技能指导Agent安全调用 CLI,针对所有子命令使用正确的参数、时间格式和认证方式。
oodlePrerequisites
前置条件
Install the CLI before running any other command in this repo:
bash
undefined在运行本仓库中的任何命令之前,请先安装CLI:
bash
undefinedInstall via Homebrew (macOS / Linux)
通过Homebrew安装(macOS / Linux)
brew install oodle-ai/oodle/oodle
brew install oodle-ai/oodle/oodle
Or via Go (any platform with Go 1.21+)
或通过Go安装(支持所有安装了Go 1.21+的平台)
go install github.com/oodle-ai/oodle-cli@latest
go install github.com/oodle-ai/oodle-cli@latest
Configure auth (interactive — writes ~/.oodle/config.yaml)
配置认证(交互式操作——会写入~/.oodle/config.yaml)
oodle configure
oodle configure
Or set env vars (preferred for CI / containers)
或设置环境变量(CI/容器环境推荐使用)
export OODLE_API_KEY=<your-api-key>
export OODLE_INSTANCE=<your-instance-id>
export OODLE_DEPLOYMENT=<your-deployment-url> # e.g. https://app.oodle.ai
Verify the CLI works before issuing any other command:
```bash
oodle version
oodle monitors list -o json | headexport OODLE_API_KEY=<your-api-key>
export OODLE_INSTANCE=<your-instance-id>
export OODLE_DEPLOYMENT=<your-deployment-url> # 示例:https://app.oodle.ai
在执行其他命令前,请验证CLI是否正常工作:
```bash
oodle version
oodle monitors list -o json | headCommand Execution Order
命令执行顺序
Before running any oodle command:
- Check whether the required resource ID or name is already in context.
- If not, run the discovery command (e.g., ).
oodle <resource> list -o json - If the result is ambiguous, ask the user to confirm before proceeding.
- Run the target command with the resolved ID.
- Do not run speculative commands (e.g., do not without first
delete-ing the resource).get
运行任何oodle命令前:
- 检查所需的资源ID或名称是否已在上下文环境中。
- 如果没有,执行发现命令(例如:)。
oodle <resource> list -o json - 如果结果不明确,请先请求用户确认再继续。
- 使用解析后的ID运行目标命令。
- 不要执行推测性命令(例如:在未先执行获取资源信息的情况下,不要执行
get命令)。delete
Quick Reference
快速参考
| Command | Purpose |
|---|---|
| Manage metric monitors |
| Manage dashboards |
| Manage dashboard folders |
| Manage notification channels |
| Manage routing of alerts to notifiers |
| Silence alerts during maintenance |
| Run PromQL instant query |
| Run PromQL range query |
| List available log index patterns |
| Search logs using OpenSearch Query DSL |
| Query metric names, labels, label values |
| Search and fetch traces |
| Manage log-derived metric rules |
| Manage HTTP/TCP synthetic checks |
| Manage metric drop / sample rules |
| Manage API keys |
| Manage users |
| Interactive auth setup |
| Install and manage agent skills (this repo) |
| 命令 | 用途 |
|---|---|
| 管理指标监控器 |
| 管理仪表盘 |
| 管理仪表盘文件夹 |
| 管理通知渠道 |
| 管理告警到通知渠道的路由规则 |
| 在维护期间静默告警 |
| 执行PromQL即时查询 |
| 执行PromQL范围查询 |
| 列出可用的日志索引模式 |
| 使用OpenSearch Query DSL搜索日志 |
| 查询指标名称、标签、标签值 |
| 搜索并获取链路追踪数据 |
| 管理日志衍生指标规则 |
| 管理HTTP/TCP合成监控检查 |
| 管理指标丢弃/采样规则 |
| 管理API密钥 |
| 管理用户 |
| 交互式认证设置 |
| 安装并管理Agent技能(本仓库) |
Common Operations
常见操作
Output formats
输出格式
-otablejsonbash
undefined-otablejsonbash
undefined✅ CORRECT — JSON for scripting; jq can parse it
✅ 正确用法 — 脚本使用JSON格式;jq可解析
oodle monitors list -o json | jq '.[].id'
oodle monitors list -o json | jq '.[].id'
✅ CORRECT — table for humans skimming a list
✅ 正确用法 — 人类浏览列表使用table格式
oodle monitors list -o table
oodle monitors list -o table
✅ CORRECT — yaml when round-tripping into a -f
input file
-f✅ 正确用法 — 当需要将结果回写到-f
输入文件时使用yaml格式
-foodle monitors get mon_123 -o yaml > monitor.yaml
oodle monitors get mon_123 -o yaml > monitor.yaml
✅ CORRECT — csv for spreadsheets / quick grep
✅ 正确用法 — 导出到电子表格/快速搜索使用csv格式
oodle metrics list --match http_ -o csv
oodle metrics list --match http_ -o csv
❌ WRONG — parsing the default table format with awk/grep is fragile
❌ 错误用法 — 使用awk/grep解析默认的table格式易出错
oodle monitors list | awk '{print $1}'
undefinedoodle monitors list | awk '{print $1}'
undefinedNon-interactive flags
非交互式参数
bash
undefinedbash
undefined✅ CORRECT — --force skips destructive-action confirmation in CI
✅ 正确用法 — 在CI环境中使用--force跳过破坏性操作的确认
oodle monitors delete mon_123 --force
oodle monitors delete mon_123 --force
❌ WRONG — running a destructive command without --force in a non-TTY pipeline
❌ 错误用法 — 在非TTY管道中运行破坏性命令时未使用--force
oodle monitors delete mon_123
undefinedoodle monitors delete mon_123
undefinedRetries on transient failures
临时故障重试
bash
undefinedbash
undefined✅ CORRECT — retry transient 5xx / network errors up to 3 times
✅ 正确用法 — 针对临时5xx/网络错误最多重试3次
oodle monitors list -o json --retries 3
oodle monitors list -o json --retries 3
❌ WRONG — wrapping the command in a custom shell loop instead of using --retries
❌ 错误用法 — 使用自定义shell循环代替--retries参数
until oodle monitors list -o json; do sleep 5; done
undefineduntil oodle monitors list -o json; do sleep 5; done
undefinedTime flags
时间参数
--from--to| Format | Example | Meaning |
|---|---|---|
| Epoch seconds | | absolute unix timestamp |
| | current server time |
| Relative duration | | now minus the duration |
bash
undefined--from--to| 格式 | 示例 | 含义 |
|---|---|---|
| 时间戳秒数 | | 绝对Unix时间戳 |
| | 当前服务器时间 |
| 相对时长 | | 当前时间减去指定时长 |
bash
undefined✅ CORRECT — relative duration is timezone-safe and readable
✅ 正确用法 — 相对时长无需考虑时区且可读性强
oodle traces list --service api --from -1h --to now -o json
oodle traces list --service api --from -1h --to now -o json
✅ CORRECT — epoch when the caller has an exact timestamp
✅ 正确用法 — 当调用者有精确时间戳时使用时间戳
oodle traces list --service api --from 1731628800 --to 1731632400 -o json
oodle traces list --service api --from 1731628800 --to 1731632400 -o json
❌ WRONG — human strings are not parsed
❌ 错误用法 — 不解析自然语言字符串
oodle traces list --service api --from "1 hour ago"
undefinedoodle traces list --service api --from "1 hour ago"
undefinedFile input (-f
)
-f文件输入(-f
)
-fcreateupdate-f <file>bash
undefinedcreateupdate-f <file>bash
undefined✅ CORRECT — JSON file
✅ 正确用法 — JSON文件
oodle monitors create -f monitor.json
oodle monitors create -f monitor.json
✅ CORRECT — YAML file
✅ 正确用法 — YAML文件
oodle monitors create -f monitor.yaml
oodle monitors create -f monitor.yaml
✅ CORRECT — round-trip through yaml for in-place edits
✅ 正确用法 — 通过yaml格式来回编写以实现就地编辑
oodle monitors get mon_123 -o yaml > monitor.yaml
$EDITOR monitor.yaml
oodle monitors update mon_123 -f monitor.yaml
oodle monitors get mon_123 -o yaml > monitor.yaml
$EDITOR monitor.yaml
oodle monitors update mon_123 -f monitor.yaml
❌ WRONG — passing JSON inline as a flag value (no -f)
❌ 错误用法 — 未使用-f参数直接传入JSON内容
oodle monitors create --body '{"name":"x"}'
undefinedoodle monitors create --body '{"name":"x"}'
undefinedBest Practices
最佳实践
Use -o json
whenever output is consumed by another tool
-o json当输出需要被其他工具消费时,请使用-o json
格式
-o jsonIf the next step in the workflow is a filter, a script, or another command, request JSON. Table output is for humans only.
jqoodlebash
undefined如果工作流的下一步是使用过滤、脚本或其他命令,请使用JSON格式。Table格式仅适合人类阅读。
jqoodlebash
undefined✅ CORRECT
✅ 正确用法
ID=$(oodle monitors list -o json | jq -r '.[] | select(.name=="High CPU") | .id')
ID=$(oodle monitors list -o json | jq -r '.[] | select(.name=="High CPU") | .id')
❌ WRONG — column positions in table output can change between releases
❌ 错误用法 — table格式的列位置可能会在版本更新时发生变化
ID=$(oodle monitors list | grep "High CPU" | awk '{print $1}')
undefinedID=$(oodle monitors list | grep "High CPU" | awk '{print $1}')
undefinedUse --force
in CI, never in interactive sessions you don't own
--force在CI环境中使用--force
,但在不属于你的交互式会话中切勿使用
--force--forcegetbash
undefined--forcegetbash
undefined✅ CORRECT — in CI: confirm the resource exists, then delete
✅ 正确用法 — 在CI环境中:先确认资源存在,再执行删除
oodle monitors get mon_123 -o json > /dev/null && oodle monitors delete mon_123 --force
oodle monitors get mon_123 -o json > /dev/null && oodle monitors delete mon_123 --force
❌ WRONG — blanket --force on a name match without verifying the ID
❌ 错误用法 — 仅通过名称匹配就使用--force,未验证ID
oodle monitors delete $(oodle monitors list | grep CPU | head -1 | awk '{print $1}') --force
undefinedoodle monitors delete $(oodle monitors list | grep CPU | head -1 | awk '{print $1}') --force
undefinedUse environment variables for credentials in CI
在CI环境中使用环境变量存储凭据
Never hardcode the API key or write it into shell history.
bash
undefined切勿硬编码API密钥或将其写入shell历史记录。
bash
undefined✅ CORRECT — credentials come from the CI secret store
✅ 正确用法 — 凭据来自CI密钥存储
export OODLE_API_KEY="$CI_OODLE_API_KEY"
export OODLE_INSTANCE="$CI_OODLE_INSTANCE"
oodle monitors list -o json
export OODLE_API_KEY="$CI_OODLE_API_KEY"
export OODLE_INSTANCE="$CI_OODLE_INSTANCE"
oodle monitors list -o json
❌ WRONG — credential in plain text on the command line
❌ 错误用法 — 在命令行中明文传递凭据
OODLE_API_KEY=sk_live_abc123 oodle monitors list -o json
undefinedOODLE_API_KEY=sk_live_abc123 oodle monitors list -o json
undefinedPin command sequences to discovered IDs
将命令序列绑定到已发现的ID
When a workflow modifies a resource, capture the ID once and reuse it.
bash
undefined当工作流需要修改资源时,只需捕获一次ID并重复使用。
bash
undefined✅ CORRECT
✅ 正确用法
ID=$(oodle monitors list -o json | jq -r '.[] | select(.name=="High CPU") | .id')
oodle monitors get "$ID" -o json
oodle monitors update "$ID" -f monitor.json
ID=$(oodle monitors list -o json | jq -r '.[] | select(.name=="High CPU") | .id')
oodle monitors get "$ID" -o json
oodle monitors update "$ID" -f monitor.json
❌ WRONG — re-resolving the name on every step (race conditions, extra latency)
❌ 错误用法 — 每一步都重新解析名称(存在竞态条件、额外延迟)
oodle monitors get $(oodle monitors list -o json | jq -r '.[] | select(.name=="High CPU") | .id')
oodle monitors update $(oodle monitors list -o json | jq -r '.[] | select(.name=="High CPU") | .id') -f monitor.json
undefinedoodle monitors get $(oodle monitors list -o json | jq -r '.[] | select(.name=="High CPU") | .id')
oodle monitors update $(oodle monitors list -o json | jq -r '.[] | select(.name=="High CPU") | .id') -f monitor.json
undefinedFailure Handling
故障处理
| Error | Cause | Fix |
|---|---|---|
| 401 Unauthorized | Invalid or missing API key | Run |
| 404 Not Found | Resource ID does not exist | Verify with |
| connection refused | Wrong | Check |
| 429 Too Many Requests | Rate limited | Add |
| CLI version too old | Upgrade with |
| File is not valid JSON/YAML | Validate with |
| 错误 | 原因 | 修复方法 |
|---|---|---|
| 401 Unauthorized | API密钥无效或缺失 | 执行 |
| 404 Not Found | 资源ID不存在 | 使用 |
| connection refused | | 检查 |
| 429 Too Many Requests | 触发速率限制 | 添加 |
| CLI版本过旧 | 使用 |
| 文件不是有效的JSON/YAML格式 | 先使用 |