datadog-pup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Datadog via Pup

通过 Pup 使用 Datadog

Pup is broad and self-describing; prefer live command discovery over memorized flags.
Pup 覆盖范围广泛且具备自描述能力;应优先实时发现命令,而不是依赖记忆中的参数。

First moves

初步步骤

  1. which pup && pup --version && pup auth status
    . This user's org is on
    datadoghq.eu
    — export
    DD_SITE=datadoghq.eu
    for the session. If auth is missing/expired, ask the user to run
    pup auth login
    or provide the right
    DD_SITE
    . Do not loop on 401/403.
  2. Discover before guessing:
    pup agent schema --compact
    (command map),
    pup agent guide
    ,
    pup <domain> --help
    .
    FORCE_AGENT_MODE=1
    turns help into JSON — never use it for writes without
    --read-only
    ; agent mode may auto-approve prompts.
  3. Prefer
    --output=json
    ,
    --read-only
    , explicit
    --from
    , and small limits:
bash
DD_SITE=datadoghq.eu pup --read-only logs search --query="status:error" --from="1h" --limit=20 --output=json
  1. which pup && pup --version && pup auth status
    。当前用户所属组织位于
    datadoghq.eu
    ——请为当前会话导出
    DD_SITE=datadoghq.eu
    。如果认证缺失或已过期,请提示用户运行
    pup auth login
    或提供正确的
    DD_SITE
    。不要在遇到 401/403 时反复重试。
  2. 先发现,再猜测:
    pup agent schema --compact
    (命令映射)、
    pup agent guide
    、
    pup <domain> --help
    。
    FORCE_AGENT_MODE=1
    会将帮助信息转换为 JSON——没有
    --read-only
    时,切勿将其用于写入操作;agent 模式可能会自动批准提示。
  3. 优先使用
    --output=json
    、
    --read-only
    、明确的
    --from
    和较小的 limit:
bash
DD_SITE=datadoghq.eu pup --read-only logs search --query="status:error" --from="1h" --limit=20 --output=json

Safety 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
    --from
    ; start narrow (15m–1h, low limits) and widen only with a reason.
  • 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 refresh
    /
    login
    or key scopes. 429: back off and narrow.
  • 将 Datadog 中的数据视为生产数据。默认使用只读模式;所有写入操作(create/update/delete、downtimes、debugger probes、workflow runs、key/user/config changes)都必须先展示确切的命令或 JSON 请求体,并获得明确确认。
  • 使用 API 端过滤和聚合;绝不要获取海量数据集后再在本地进行后处理。始终传入
    --from
    ;先从较小范围开始(15m–1h、较低的 limit),仅在有充分理由时扩大范围。
  • 除非明确需要,否则应对 secrets、tokens、emails、user IDs 和敏感属性进行脱敏。保留 IDs 和 links,以便对发现结果进行审计。
  • 遇到 401/403:停止操作,报告认证或 scope 问题,并建议使用
    pup auth refresh
    /
    login
    或调整 key scopes。遇到 429:退避并收窄查询范围。

Common read workflows

常见只读工作流

Logs — count first, then sample. Query syntax:
status:error
,
service:api
,
env:prod
,
@http.status_code:[500 TO 599]
, quoted phrases,
AND
/
OR
, negation:
bash
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
Metrics — 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=json
APM/traces — durations in trace search are often nanoseconds:
1s = 1000000000
:
bash
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=json
Monitors/SLOs/incidents — filter monitor lists by
service:
/
team:
/
env:
/status in large orgs:
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=json
Service Catalog — use before guessing ownership, on-call, dependencies, or health:
pup --read-only idp find|assist|owner|deps <service> --output=json
.
Live 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-locations
Run a probe watch in hc so it doesn't block you:
hc run --bg --name pup-watch pup debugger probes watch <id> --timeout 60 --limit 10 --fields message,captures,timestamp
, then
hc wait pup-watch
and
hc read pup-watch
.
日志——先统计,再抽样。查询语法:
status:error
、
service:api
、
env:prod
、
@http.status_code:[500 TO 599]
、带引号的短语、
AND
/
OR
、否定查询:
bash
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=json
APM/traces——trace 搜索中的 duration 通常以纳秒为单位:
1s = 1000000000
:
bash
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=json
Monitors/SLOs/incidents——在大型组织中,按
service:
/
team:
/
env:
或 status 筛选 monitor 列表:
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=json
Service Catalog——在推测服务归属、on-call、依赖关系或健康状态之前,先使用:
pup --read-only idp find|assist|owner|deps <service> --output=json
。
Live 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,timestamp
,然后执行
hc wait pup-watch
和
hc read pup-watch
。

Writes

写入操作

Explain the change → prepare a body file (
pup monitors create --file monitor.json
) → 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.
--yes
only after user approval, never to bypass ambiguity.
说明变更 → 准备请求体文件(
pup monitors create --file monitor.json
)→ 使用 list/get 进行验证 → 展示确切命令 → 获得确认 → 以最小范围执行 → 通过只读查询进行验证 → 记录已创建的 IDs 和回滚步骤。只有在用户批准后才能使用
--yes
,绝不可用它绕过歧义。

Domain map

领域映射

pup agent schema --compact
for the live list. Common:
logs
,
metrics
,
traces
,
apm
,
monitors
/
downtime
,
slos
,
incidents
/
on-call
/
cases
,
dashboards
/
notebooks
,
idp
/
service-catalog
,
security
/
audit-logs
/
csm-threats
,
rum
/
synthetics
/
error-tracking
,
cloud
/
infrastructure
/
containers
/
network
/
processes
,
usage
/
costs
,
debugger
/
symdb
,
workflows
/
runbooks
/
investigations
/
bits
.
Some 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 --compact
获取实时列表。常见领域:
logs
、
metrics
、
traces
、
apm
、
monitors
/
downtime
、
slos
、
incidents
/
on-call
/
cases
、
dashboards
/
notebooks
、
idp
/
service-catalog
、
security
/
audit-logs
/
csm-threats
、
rum
/
synthetics
/
error-tracking
、
cloud
/
infrastructure
/
containers
/
network
/
processes
、
usage
/
costs
、
debugger
/
symdb
、
workflows
/
runbooks
/
investigations
/
bits
。
即使使用 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 延迟/错误 → 基础设施指标 → 活跃事件。