dd-pup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesepup (Datadog CLI)
pup(Datadog CLI)
Pup CLI for Datadog API operations. Supports OAuth2 and API key auth.
用于执行Datadog API操作的Pup CLI,支持OAuth2和API密钥身份验证。
Quick Reference
快速参考
| Task | Command |
|---|---|
| Search error logs | |
| List monitors | |
| Mute a monitor | |
| Find slow traces | |
| List active incidents | |
| Create incident | |
| Query metrics | |
| List hosts | |
| Check SLOs | |
| Who's on call | |
| Security signals | |
| Check auth | |
| Refresh token | |
| 任务 | 命令 |
|---|---|
| 搜索错误日志 | |
| 列出监控项 | |
| 静音监控项 | |
| 查询慢链路 | |
| 列出活跃事件 | |
| 创建事件 | |
| 查询指标 | |
| 列出主机 | |
| 检查SLO | |
| 查询值班人员 | |
| 查看安全信号 | |
| 检查身份验证状态 | |
| 刷新令牌 | |
Prerequisites
前置要求
bash
undefinedbash
undefinedInstall pup
Install pup
go install github.com/datadog-labs/pup@latest
export PATH="$HOME/go/bin:$PATH"
undefinedgo install github.com/datadog-labs/pup@latest
export PATH="$HOME/go/bin:$PATH"
undefinedAuth
身份验证
bash
pup auth login # OAuth2 browser flow (recommended)
pup auth status # Check token validity
pup auth refresh # Refresh expired token (no browser)
pup auth logout # Clear credentials⚠️ Tokens expire (~1 hour). If a command fails with 401/403 mid-conversation:
bash
pup auth refresh # Try refresh first
pup auth login # If refresh fails, full re-authbash
pup auth login # OAuth2浏览器流程(推荐)
pup auth status # 检查令牌有效性
pup auth refresh # 刷新过期令牌(无需浏览器)
pup auth logout # 清除凭证⚠️ 令牌有效期约1小时。如果命令执行过程中返回401/403错误:
bash
pup auth refresh # 先尝试刷新令牌
pup auth login # 如果刷新失败,重新完成完整身份验证Headless/CI (no browser)
无界面/CI场景(无浏览器)
bash
undefinedbash
undefinedUse env vars or:
使用环境变量或:
export DD_API_KEY=your-api-key
export DD_APP_KEY=your-app-key
export DD_SITE=datadoghq.com # or datadoghq.eu, etc.
undefinedexport DD_API_KEY=your-api-key
export DD_APP_KEY=your-app-key
export DD_SITE=datadoghq.com # 或 datadoghq.eu 等
undefinedCommand Reference
命令参考
Monitors
监控项
bash
pup monitors list --limit 10
pup monitors list --tags "env:prod"
pup monitors get --id 12345
pup monitors mute --id 12345 --duration 1h
pup monitors unmute --id 12345
pup monitors create --name "High CPU" --type "metric alert" \
--query "avg(last_5m):avg:system.cpu.user{*} > 80" \
--message "CPU high @slack-ops"bash
pup monitors list --limit 10
pup monitors list --tags "env:prod"
pup monitors get --id 12345
pup monitors mute --id 12345 --duration 1h
pup monitors unmute --id 12345
pup monitors create --name "High CPU" --type "metric alert" \
--query "avg(last_5m):avg:system.cpu.user{*} > 80" \
--message "CPU high @slack-ops"Logs
日志
bash
pup logs search --query "status:error" --duration 1h
pup logs search --query "service:payment-api" --duration 1h --limit 100
pup logs search --query "@http.status_code:5*" --duration 24h
pup logs search --query "env:prod level:error" --duration 1h --jsonbash
pup logs search --query "status:error" --duration 1h
pup logs search --query "service:payment-api" --duration 1h --limit 100
pup logs search --query "@http.status_code:5*" --duration 24h
pup logs search --query "env:prod level:error" --duration 1h --jsonMetrics
指标
bash
pup metrics query --query "avg:system.cpu.user{*}" --duration 1h
pup metrics query --query "sum:trace.express.request.hits{service:api}" --duration 1h
pup metrics list --filter "system.*"bash
pup metrics query --query "avg:system.cpu.user{*}" --duration 1h
pup metrics query --query "sum:trace.express.request.hits{service:api}" --duration 1h
pup metrics list --filter "system.*"APM / Traces
APM / 链路追踪
bash
pup apm services list
pup apm traces list --service my-service --duration 1h
pup apm traces list --service api --min-duration 500ms --duration 1h
pup apm traces list --service api --status error --duration 1h
pup apm traces get abc123def456bash
pup apm services list
pup apm traces list --service my-service --duration 1h
pup apm traces list --service api --min-duration 500ms --duration 1h
pup apm traces list --service api --status error --duration 1h
pup apm traces get abc123def456Incidents
事件
bash
pup incidents list --status active
pup incidents list --status resolved --duration 7d
pup incidents create --title "API Degradation" --severity SEV-2
pup incidents update --id abc-123 --status stable
pup incidents resolve --id abc-123bash
pup incidents list --status active
pup incidents list --status resolved --duration 7d
pup incidents create --title "API Degradation" --severity SEV-2
pup incidents update --id abc-123 --status stable
pup incidents resolve --id abc-123Dashboards
仪表盘
bash
pup dashboards list
pup dashboards list --tags "team:platform"
pup dashboards get --id abc-123
pup dashboards create --title "My Dashboard" --description "..." --widgets '[...]'bash
pup dashboards list
pup dashboards list --tags "team:platform"
pup dashboards get --id abc-123
pup dashboards create --title "My Dashboard" --description "..." --widgets '[...]'SLOs
SLO
bash
pup slos list
pup slos get --id slo-123
pup slos history --id slo-123 --duration 30dbash
pup slos list
pup slos get --id slo-123
pup slos history --id slo-123 --duration 30dSynthetics
合成监控
bash
pup synthetics list
pup synthetics results --test-id abc-123
pup synthetics trigger --test-id abc-123bash
pup synthetics list
pup synthetics results --test-id abc-123
pup synthetics trigger --test-id abc-123On-Call
值班
bash
pup on-call teams list
pup on-call schedules list
pup on-call who --team platform-teambash
pup on-call teams list
pup on-call schedules list
pup on-call who --team platform-teamHosts / Infrastructure
主机 / 基础设施
bash
pup hosts list --limit 50
pup hosts list --filter "env:prod"
pup hosts mute --hostname web-01 --duration 1h
pup hosts get --hostname web-01bash
pup hosts list --limit 50
pup hosts list --filter "env:prod"
pup hosts mute --hostname web-01 --duration 1h
pup hosts get --hostname web-01Events
事件
bash
pup events list --duration 24h
pup events list --tags "source:deploy"
pup events post --title "Deploy started" --text "v1.2.3" --tags "env:prod"bash
pup events list --duration 24h
pup events list --tags "source:deploy"
pup events post --title "Deploy started" --text "v1.2.3" --tags "env:prod"Downtimes
计划维护
bash
pup downtime list
pup downtime create --scope "env:staging" --duration 2h --message "Maintenance"
pup downtime cancel --id 12345bash
pup downtime list
pup downtime create --scope "env:staging" --duration 2h --message "Maintenance"
pup downtime cancel --id 12345Users / Teams
用户 / 团队
bash
pup users list
pup teams listbash
pup users list
pup teams listSecurity
安全
bash
pup security signals list --duration 24h
pup security signals list --severity criticalbash
pup security signals list --duration 24h
pup security signals list --severity criticalService Catalog
服务目录
bash
pup services list
pup services get --name payment-apibash
pup services list
pup services get --name payment-apiNotebooks
笔记本
bash
pup notebooks list
pup notebooks get --id 12345bash
pup notebooks list
pup notebooks get --id 12345Workflows
工作流
bash
pup workflows list
pup workflows trigger --id workflow-123 --input '{"key": "value"}'bash
pup workflows list
pup workflows trigger --id workflow-123 --input '{"key": "value"}'Subcommand Discovery
子命令查询
bash
pup --help # List all commands
pup <command> --help # Command-specific helpbash
pup --help # 列出所有命令
pup <command> --help # 查看特定命令的帮助信息Error Handling
错误处理
| Error | Cause | Fix |
|---|---|---|
| 401 Unauthorized | Token expired | |
| 403 Forbidden | Missing scope | Check app key permissions |
| 404 Not Found | Wrong ID/resource | Verify resource exists |
| Rate limited | Too many requests | Add delays between calls |
| 错误 | 原因 | 解决方案 |
|---|---|---|
| 401 Unauthorized | 令牌过期 | |
| 403 Forbidden | 缺少权限范围 | 检查应用密钥权限 |
| 404 Not Found | ID/资源错误 | 确认资源存在 |
| Rate limited | 请求过多 | 在请求之间添加延迟 |
Install
安装
bash
go install github.com/DataDog/pup@latestbash
go install github.com/DataDog/pup@latestVerify Installation
验证安装
bash
undefinedbash
undefinedCheck if pup is in PATH
Check if pup is in PATH
which pup
which pup
If not found, check if it was installed
If not found, check if it was installed
ls ~/go/bin/pup
undefinedls ~/go/bin/pup
undefinedPATH Troubleshooting
PATH问题排查
If is installed but returns nothing, Go's bin directory isn't in your PATH.
pupwhich pupCheck where pup is:
bash
ls ~/go/bin/pup # Standard location
ls $GOPATH/bin/pup # If GOPATH is set
ls $GOBIN/pup # If GOBIN is setAdd to PATH (pick your shell):
For zsh (macOS default):
bash
undefined如果已安装但无返回,说明Go的bin目录不在你的PATH中。
pupwhich pup检查pup的安装位置:
bash
ls ~/go/bin/pup # 标准位置
ls $GOPATH/bin/pup # 如果设置了GOPATH
ls $GOBIN/pup # 如果设置了GOBIN添加到PATH(选择对应的shell):
对于zsh(macOS默认shell):
bash
undefinedAdd this line to ~/.zshrc
Add this line to ~/.zshrc
export PATH="$HOME/go/bin:$PATH"
export PATH="$HOME/go/bin:$PATH"
Then reload
Then reload
source ~/.zshrc
For **bash**:
```bashsource ~/.zshrc
对于**bash**:
```bashAdd this line to ~/.bashrc or ~/.bash_profile
Add this line to ~/.bashrc or ~/.bash_profile
export PATH="$HOME/go/bin:$PATH"
export PATH="$HOME/go/bin:$PATH"
Then reload
Then reload
source ~/.bashrc
For **fish**:
```fishsource ~/.bashrc
对于**fish**:
```fishAdd this line to ~/.config/fish/config.fish
Add this line to ~/.config/fish/config.fish
fish_add_path $HOME/go/bin
fish_add_path $HOME/go/bin
Or set permanently
Or set permanently
set -Ux fish_user_paths $HOME/go/bin $fish_user_paths
set -Ux fish_user_paths $HOME/go/bin $fish_user_paths
Then reload
Then reload
source ~/.config/fish/config.fish
**Verify:**
```bash
which pup # Should show path
pup --version # Should show versionsource ~/.config/fish/config.fish
**验证:**
```bash
which pup # 应返回pup的路径
pup --version # 应返回版本号Alternative: Full Path
替代方案:使用完整路径
If you don't want to modify PATH, use the full path:
bash
~/go/bin/pup auth login
~/go/bin/pup monitors listOr create an alias:
bash
alias pup="$HOME/go/bin/pup"如果你不想修改PATH,可以直接使用完整路径:
bash
~/go/bin/pup auth login
~/go/bin/pup monitors list或者创建别名:
bash
alias pup="$HOME/go/bin/pup"Sites
站点
| Site | |
|---|---|
| US1 (default) | |
| US3 | |
| US5 | |
| EU1 | |
| AP1 | |
| US1-FED | |
| 站点 | |
|---|---|
| US1(默认) | |
| US3 | |
| US5 | |
| EU1 | |
| AP1 | |
| US1-FED | |