datadog-pup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDatadog via Pup
通过 Pup 使用 Datadog
Pup is broad and self-describing; prefer live command discovery over memorized flags.
Pup 覆盖范围广泛且具备自描述能力;应优先实时发现命令,而不是依赖记忆中的参数。
First moves
初步步骤
- . This user's org is on
which pup && pup --version && pup auth status— exportdatadoghq.eufor the session. If auth is missing/expired, ask the user to runDD_SITE=datadoghq.euor provide the rightpup auth login. Do not loop on 401/403.DD_SITE - Discover before guessing: (command map),
pup agent schema --compact,pup agent guide.pup <domain> --helpturns help into JSON — never use it for writes withoutFORCE_AGENT_MODE=1; agent mode may auto-approve prompts.--read-only - Prefer ,
--output=json, explicit--read-only, and small limits:--from
bash
DD_SITE=datadoghq.eu pup --read-only logs search --query="status:error" --from="1h" --limit=20 --output=json- 。当前用户所属组织位于
which pup && pup --version && pup auth status——请为当前会话导出datadoghq.eu。如果认证缺失或已过期,请提示用户运行DD_SITE=datadoghq.eu或提供正确的pup auth login。不要在遇到 401/403 时反复重试。DD_SITE - 先发现,再猜测:(命令映射)、
pup agent schema --compact、pup agent guide。pup <domain> --help会将帮助信息转换为 JSON——没有FORCE_AGENT_MODE=1时,切勿将其用于写入操作;agent 模式可能会自动批准提示。--read-only - 优先使用 、
--output=json、明确的--read-only和较小的 limit:--from
bash
DD_SITE=datadoghq.eu pup --read-only logs search --query="status:error" --from="1h" --limit=20 --output=jsonSafety rules
安全规则
- Treat Datadog as production data. Default to read-only; writes (create/update/delete, downtimes, debugger probes, workflow runs, key/user/config changes) need explicit confirmation with the exact command or JSON body shown first.
- Use API-side filters/aggregation; never fetch huge datasets to post-process locally. Always pass ; start narrow (15m–1h, low limits) and widen only with a reason.
--from - Redact secrets, tokens, emails, user IDs, and sensitive attributes unless explicitly needed. Preserve IDs and links so findings are auditable.
- 401/403: stop, report auth/scope issue, suggest /
pup auth refreshor key scopes. 429: back off and narrow.login
- 将 Datadog 中的数据视为生产数据。默认使用只读模式;所有写入操作(create/update/delete、downtimes、debugger probes、workflow runs、key/user/config changes)都必须先展示确切的命令或 JSON 请求体,并获得明确确认。
- 使用 API 端过滤和聚合;绝不要获取海量数据集后再在本地进行后处理。始终传入 ;先从较小范围开始(15m–1h、较低的 limit),仅在有充分理由时扩大范围。
--from - 除非明确需要,否则应对 secrets、tokens、emails、user IDs 和敏感属性进行脱敏。保留 IDs 和 links,以便对发现结果进行审计。
- 遇到 401/403:停止操作,报告认证或 scope 问题,并建议使用 /
pup auth refresh或调整 key scopes。遇到 429:退避并收窄查询范围。login
Common read workflows
常见只读工作流
Logs — count first, then sample. Query syntax: , , , , quoted phrases, /, negation:
status:errorservice:apienv:prod@http.status_code:[500 TO 599]ANDORbash
pup --read-only logs aggregate --query="status:error env:prod" --from="1h" --compute="count" --group-by="service" --output=json
pup --read-only logs search --query="status:error env:prod service:<svc>" --from="1h" --limit=20 --output=jsonMetrics — shape :
<aggregation>:<metric>{<scope>} by {<group>}bash
pup --read-only metrics query --query="avg:system.cpu.user{env:prod} by {host}" --from="1h" --output=json
pup --read-only metrics list --filter="trace.*" --output=jsonAPM/traces — durations in trace search are often nanoseconds: :
1s = 1000000000bash
pup --read-only apm services stats --env production --from="1h" --output=json
pup --read-only traces search --query="service:<svc> status:error" --from="1h" --limit=20 --output=json
pup --read-only traces aggregate --query="service:<svc>" --from="1h" --compute="avg(@duration)" --group-by="resource_name" --output=jsonMonitors/SLOs/incidents — filter monitor lists by ///status in large orgs:
service:team:env:bash
pup --read-only monitors search --query="status:Alert" --output=json
pup --read-only slos list --output=json
pup --read-only incidents list --query="status:active" --output=jsonService Catalog — use before guessing ownership, on-call, dependencies, or health: .
pup --read-only idp find|assist|owner|deps <service> --output=jsonLive Debugger / Symbol DB — can affect production; explicit user approval only. Before creating a probe confirm service, env, location, captures, TTL, and cleanup; prefer capture expressions over full snapshots; short TTL; delete after use.
bash
pup --read-only debugger context <service> --fields service,language,envs
pup --read-only symdb search --service <service> --query "Controller" --view probe-locationsRun a probe watch in hc so it doesn't block you: , then and .
hc run --bg --name pup-watch pup debugger probes watch <id> --timeout 60 --limit 10 --fields message,captures,timestamphc wait pup-watchhc read pup-watch日志——先统计,再抽样。查询语法:、、、、带引号的短语、/、否定查询:
status:errorservice:apienv:prod@http.status_code:[500 TO 599]ANDORbash
pup --read-only logs aggregate --query="status:error env:prod" --from="1h" --compute="count" --group-by="service" --output=json
pup --read-only logs search --query="status:error env:prod service:<svc>" --from="1h" --limit=20 --output=json指标——按 构造查询:
<aggregation>:<metric>{<scope>} by {<group>}bash
pup --read-only metrics query --query="avg:system.cpu.user{env:prod} by {host}" --from="1h" --output=json
pup --read-only metrics list --filter="trace.*" --output=jsonAPM/traces——trace 搜索中的 duration 通常以纳秒为单位::
1s = 1000000000bash
pup --read-only apm services stats --env production --from="1h" --output=json
pup --read-only traces search --query="service:<svc> status:error" --from="1h" --limit=20 --output=json
pup --read-only traces aggregate --query="service:<svc>" --from="1h" --compute="avg(@duration)" --group-by="resource_name" --output=jsonMonitors/SLOs/incidents——在大型组织中,按 // 或 status 筛选 monitor 列表:
service:team:env:bash
pup --read-only monitors search --query="status:Alert" --output=json
pup --read-only slos list --output=json
pup --read-only incidents list --query="status:active" --output=jsonService Catalog——在推测服务归属、on-call、依赖关系或健康状态之前,先使用:。
pup --read-only idp find|assist|owner|deps <service> --output=jsonLive Debugger / Symbol DB——可能影响生产环境;仅在用户明确批准后使用。创建 probe 前,应确认 service、env、location、captures、TTL 和 cleanup;优先使用 capture expressions,而不是完整 snapshots;使用较短的 TTL;使用后删除。
bash
pup --read-only debugger context <service> --fields service,language,envs
pup --read-only symdb search --service <service> --query "Controller" --view probe-locations在 hc 中运行 probe watch,避免阻塞当前操作:,然后执行 和 。
hc run --bg --name pup-watch pup debugger probes watch <id> --timeout 60 --limit 10 --fields message,captures,timestamphc wait pup-watchhc read pup-watchWrites
写入操作
Explain the change → prepare a body file () → validate with list/get → show the exact command → get confirmation → execute with the smallest scope → verify with a read → record created IDs and rollback steps. only after user approval, never to bypass ambiguity.
pup monitors create --file monitor.json--yes说明变更 → 准备请求体文件()→ 使用 list/get 进行验证 → 展示确切命令 → 获得确认 → 以最小范围执行 → 通过只读查询进行验证 → 记录已创建的 IDs 和回滚步骤。只有在用户批准后才能使用 ,绝不可用它绕过歧义。
pup monitors create --file monitor.json--yesDomain map
领域映射
pup agent schema --compactlogsmetricstracesapmmonitorsdowntimeslosincidentson-callcasesdashboardsnotebooksidpservice-catalogsecurityaudit-logscsm-threatsrumsyntheticserror-trackingcloudinfrastructurecontainersnetworkprocessesusagecostsdebuggersymdbworkflowsrunbooksinvestigationsbitsSome domains need API/app keys even with OAuth; if scopes are unsupported/insufficient, report it and ask for the right credential path.
使用 获取实时列表。常见领域:、、、、/、、//、/、/、//、//、////、/、/、///。
pup agent schema --compactlogsmetricstracesapmmonitorsdowntimeslosincidentson-callcasesdashboardsnotebooksidpservice-catalogsecurityaudit-logscsm-threatsrumsyntheticserror-trackingcloudinfrastructurecontainersnetworkprocessesusagecostsdebuggersymdbworkflowsrunbooksinvestigationsbits即使使用 OAuth,某些领域仍需要 API/app keys;如果不支持相关 scopes 或权限不足,请报告此情况,并提示用户提供正确的 credential path。
Reporting
报告
Summarize — no raw JSON dumps unless requested: what I checked (command + range + filters), findings (counts/trends/top offenders + IDs/links), caveats (auth/site/sampling/retention), and one or two next safe queries. For incidents, preserve chronology: deploys/events → monitor state → log spikes → trace latency/errors → infra metrics → active incidents.
进行总结——除非明确要求,否则不要直接转储原始 JSON:说明检查了什么(命令 + 时间范围 + 筛选条件)、发现的问题(计数/趋势/主要问题来源 + IDs/links)、注意事项(认证/site/采样/保留策略),以及一到两条后续安全查询。对于事件,应保留时间线:部署/事件 → 监控器状态 → 日志突增 → trace 延迟/错误 → 基础设施指标 → 活跃事件。