SuperAPI AI 工具集

dd-pup

部署与运维

查看项目

更新于 10-15 20:33

技能介绍

pup 是 Datadog 的命令行工具(Rust 实现),用于通过 CLI 调用 Datadog API,覆盖日志、指标、APM/追踪、监控器、事件、SLO、合成测试、值班、主机、安全信号、审计日志、服务目录、笔记本、工作流、可观测性管道、LLM 可观测性、参考表与成本配置等操作。

认证支持 OAuth2 浏览器流程与 API Key。常用命令:pup auth login、pup auth status、pup auth refresh、pup auth logout。令牌约 1 小时过期,命令返回 401/403 时可先 pup auth refresh,失败再重新登录。无浏览器环境(CI)可设置环境变量:export DD_API_KEY=your-api-key、export DD_APP_KEY=your-app-key、export DD_SITE=datadoghq.com(或 datadoghq.eu 等)。

典型用法示例:pup logs search --query "status:error" --from 1h;pup monitors list;pup monitors diff <monitor-id> monitor.json;pup downtime create --file downtime.json;pup traces search --query "service:<service-name> @duration:>500ms" --from 1h;pup metrics query --query "avg:system.cpu.user{*}";pup incidents list --limit 50;pup security signals list --query "status:open severity:critical" --from 1h --limit 100;pup audit-logs search --query "@action:deleted" --from 24h。

使用前需先安装 pup(安装步骤见 Setup Pup),可用 which pup 与 pup --version 验证。命令中涉及 <env>、<service-name>、<team-id> 等占位符时,应先从上下文或发现类命令(list/search)获取真实值,无法确定时向用户确认,禁止直接运行含未解析占位符的命令。

限制与注意事项:pup 1.6.3 不提供仪表盘版本历史,如需精确历史版本且无不可变快照,应在 Datadog UI 中查看;仪表盘创建/克隆/更新需先以 --read-only 保存源快照,删除响应专有字段后再提交,并对比目标定义与布局投影;无 pup monitors mute/unmute 命令,需用 downtime 载荷替代;错误处理包括 401 刷新令牌、403 检查应用密钥权限、404 核对资源 ID、限流时增加调用间隔。站点通过 DD_SITE 指定,如 datadoghq.com、us3.datadoghq.com、us5.datadoghq.com、datadoghq.eu、ap1.datadoghq.com、ap2.datadoghq.com、ddog-gov.com。