Dd Pup

作者 datadog-labs5b40c73824ec無授權條款177 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫今天更新

Datadog CLI (Rust). OAuth2 auth with token refresh.

僅含說明DevOps & Cloud
AI 產生的概覽

使用 pup CLI 執行 Datadog API 操作的參考指南,涵蓋日誌、監控器、指標、事件與稽核日誌等。

功能
此技能是 pup(以 Rust 撰寫的 Datadog CLI)的命令參考。它列出用於搜尋日誌、追蹤與稽核日誌,查詢指標,以及管理監控器、儀表板、SLO、停機、事件、安全訊號等 Datadog 資源的命令。它也涵蓋 OAuth2 與 API 金鑰驗證、權杖更新、站點選擇、錯誤處理,以及安全的儀表板複製與更新流程。它產出的是命令呼叫與操作指引,而非檔案。
適用情境
當代理程式需要透過 pup CLI 查詢或修改 Datadog 資源時使用,例如排查錯誤日誌、檢查監控器或 SLO,或調查稽核活動。當驗證失敗、需要更新權杖,或在無瀏覽器環境設定 API 金鑰時也適用。
執行需求
需要安裝 pup CLI,並提供 Datadog 認證:OAuth2 登入,或 DD_API_KEY、DD_APP_KEY 與 DD_SITE 環境變數。需要連線至 Datadog API 的網路存取。此技能不含指令碼,僅為說明文件。

pup (Datadog CLI)

Pup CLI for Datadog API operations. Supports OAuth2 and API key auth.

Quick Reference

TaskCommand
Search error logspup logs search --query "status:error" --from 1h
List monitorspup monitors list
Diff a monitor definitionpup monitors diff <monitor-id> monitor.json
Schedule monitor downtimepup downtime create --file downtime.json
Open a dashboard at a live time windowpup dashboards url <dashboard-id> --from now-1h --to now --live true
Find recent slow traces for a service (last 1h)pup traces search --query "service:<service-name> @duration:>500ms" --from 1h
List incidentspup incidents list --limit 50
Import incident payloadpup incidents import --file incident.json
Query metricspup metrics query --query "avg:system.cpu.user{*}"
List hostspup infrastructure hosts list --count 50
Check SLOspup slos list
On-call teamspup on-call teams list
Triage open critical security signals (last 1h)pup security signals list --query "status:open severity:critical" --from 1h --limit 100
Search audit logspup audit-logs search --query "@action:deleted" --from 24h
Audit activity by userpup audit-logs search --query "@usr.email:[email protected]" --from 7d
Investigate API keypup audit-logs search --query "@metadata.api_key.id:KEY_ID" --from 90d
Check authpup auth status
Token expiry (time left)pup auth status
Refresh tokenpup auth refresh

Prerequisites

Install pup using the setup instructions.

Required Input Resolution

For commands that need specific scope values (<env>, <service-name>, <team-id>, resource IDs), use this order:

  1. Check context first (conversation history, prior command output, saved variables).
  2. If missing, run a discovery command first (list/search) to get valid values.
  3. If still missing or ambiguous, ask the user to confirm the exact value.
  4. Then run the target command.
  5. Never run commands with unresolved placeholders like <env> or <monitor-id>.

Auth

bash
pup auth login          # OAuth2 browser flow (recommended)pup auth status         # Check token validitypup 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 firstpup auth login          # If refresh fails, full re-auth

If Chrome opens the wrong profile/window, use the one-time OAuth URL printed by pup auth login (If the browser doesn't open, visit: ...) and open that link manually in the correct account session.

Headless/CI (no browser)

bash
# Use env vars or:export DD_API_KEY=your-api-keyexport DD_APP_KEY=your-app-keyexport DD_SITE=datadoghq.com    # or datadoghq.eu, etc.

Command Reference

Monitors

bash
pup monitors list --limit 10pup monitors list --tags "env:<env>"pup monitors get <monitor-id>pup monitors search --query "<monitor-name>"pup monitors create --file monitor.jsonpup monitors update <monitor-id> --file monitor.jsonpup monitors diff <monitor-id> monitor.jsonpup monitors delete <monitor-id># No pup monitors mute/unmute commands; use downtime payloads instead.pup downtime create --file downtime.json

Logs

bash
pup logs search --query "status:error" --from 1hpup logs search --query "service:<service-name>" --from 1h --limit 100pup logs search --query "@http.status_code:5*" --from 24hpup logs search --query "env:<env> level:error" --from 1hpup logs aggregate --query "service:<service-name>" --compute count --from 1h

Metrics

bash
pup metrics query --query "avg:system.cpu.user{*}" --from 1h --to nowpup metrics query --query "sum:trace.express.request.hits{service:<service-name>}" --from 1h --to nowpup metrics list --filter "system.*"

APM / Traces

bash
# Confirm env tag with the user first (do not assume production/prod/prd).pup apm services list --env <env> --from 1h --to nowpup traces search --query "service:<service-name>" --from 1hpup traces search --query "service:<service-name> @duration:>500ms" --from 1hpup traces search --query "service:<service-name> status:error" --from 1h

Incidents

bash
pup incidents list --limit 50pup incidents get <incident-id>pup incidents import --file incident.json

Dashboards

bash
pup dashboards listpup dashboards get <dashboard-id> --read-onlypup dashboards url <dashboard-id> --from now-1h --to now --live truepup dashboards create --file dashboard.jsonpup dashboards update <dashboard-id> --file dashboard.jsonpup dashboards delete <dashboard-id>
Safe dashboard create, clone, and update workflow

The goal is a recoverable source and a verified destination. A successful API response alone does not prove that widget content or placement was preserved.

  1. Fetch the source or update target with --read-only and save the exact response as an immutable snapshot. Never overwrite this file with transformed JSON.
    bash
    pup dashboards get <dashboard-id> --read-only -o json > dashboard-source.json
  2. Build a separate mutation payload. Remove response-only fields before create/update: author_handle, author_name, created_at, id, modified_at, and url.
    bash
    jq 'del(.author_handle, .author_name, .created_at, .id, .modified_at, .url)' \  dashboard-source.json > dashboard-payload.json
  3. For a backup or clone, leave the source dashboard unchanged and change only explicitly requested fields, usually title or description. Preserve layout_type, reflow_type, widget order, and every recursive widget layout object (x, y, width, height, and is_column_break). Repacking or compacting coordinates creates a derived layout, not an exact clone.
  4. Create or update from dashboard-payload.json, then fetch the destination into a new file.
    bash
    pup dashboards create --file dashboard-payload.jsonpup dashboards get <destination-id> --read-only -o json > dashboard-destination.json
  5. Normalize away the response-only fields and compare the complete definitions. The only differences should be the fields intentionally changed.
  6. Also compare layout projections separately so a placement regression cannot hide in a large widget diff:
    bash
    jq '{layout_type, reflow_type, layouts: [.. | objects | .layout? // empty]}' dashboard-source.jsonjq '{layout_type, reflow_type, layouts: [.. | objects | .layout? // empty]}' dashboard-destination.json

Pup 1.6.3 does not expose dashboard version history. If an exact historical version is required and no immutable snapshot exists, inspect version history in the Datadog UI before changing the dashboard.

SLOs

bash
pup slos listpup slos get <slo-id>pup slos status <slo-id> --from 30d --to nowpup slos create --file slo.json

Synthetics

bash
pup synthetics tests listpup synthetics tests get <test-id>pup synthetics tests search --text "login"pup synthetics locations list

On-Call

bash
pup on-call teams list# Pick a real team id from `pup on-call teams list` output.pup on-call teams get <team-id>pup on-call teams memberships list <team-id>

Hosts / Infrastructure

bash
pup infrastructure hosts list --count 50pup infrastructure hosts list --filter "env:<env>"pup infrastructure hosts get <host-name>

Events

bash
pup events list --from 24hpup events list --tags "source:deploy"pup events search --query "deploy" --from 24h --limit 50pup events get <event-id>

Downtimes

bash
pup downtime listpup downtime create --file downtime.jsonpup downtime cancel <downtime-id>

Users / Teams

bash
pup users listpup users get <user-id>

Security

bash
pup security signals list --query "*" --from 1h --limit 100pup security signals list --query "status:open severity:critical" --from 1h --limit 100# Broader lookback for historical triagepup security signals list --query "severity:critical" --from 24h --limit 100

Audit Logs

bash
# List recent eventspup audit-logs list --from 1h --limit 100
# Search with query (Lucene syntax, same as Log Explorer)pup audit-logs search --query "@action:deleted" --from 24hpup audit-logs search --query "@usr.email:[email protected]" --from 7dpup audit-logs search --query "@evt.name:Authentication @action:login" --from 7dpup audit-logs search --query "@metadata.api_key.id:KEY_ID" --from 90d --limit 200
# JSON output for piping to jqpup audit-logs search --query "@action:deleted" --from 24h -o json | jq '.data[].attributes'
# audit-logs is the long form (both work)pup audit-logs search --query "@evt.name:Monitor @action:modified" --from 7d

Service Catalog

bash
pup service-catalog listpup service-catalog get <service-name>

Notebooks

bash
pup notebooks listpup notebooks get <notebook-id>

Workflows

bash
pup workflows get <workflow-id>pup workflows run <workflow-id> --payload '{"key":"value"}'pup workflows instances list <workflow-id>

Observability Pipelines

bash
pup obs-pipelines list --limit 50pup obs-pipelines get <pipeline-id>pup obs-pipelines create --file pipeline.jsonpup obs-pipelines update <pipeline-id> --file pipeline.jsonpup obs-pipelines delete <pipeline-id>pup obs-pipelines validate --file pipeline.json

LLM Observability

bash
pup llm-obs projects listpup llm-obs projects create --file project.jsonpup llm-obs experiments listpup llm-obs experiments list --filter-project-id <project-id>pup llm-obs experiments list --filter-dataset-id <dataset-id>pup llm-obs experiments create --file experiment.jsonpup llm-obs experiments update <experiment-id> --file experiment.jsonpup llm-obs experiments delete --file delete-request.jsonpup llm-obs datasets list --project-id <project-id>pup llm-obs datasets create --project-id <project-id> --file dataset.jsonpup llm-obs spans search --ml-app <ml-app-name> --from 1h --limit 20

Reference Tables

bash
pup reference-tables list --limit 50pup reference-tables get <table-id>pup reference-tables create --file table.jsonpup reference-tables batch-query --file query.json

Cost Cloud Configs

bash
# AWS CUR configspup cost aws-config listpup cost aws-config get <account-id>pup cost aws-config create --file config.jsonpup cost aws-config delete <account-id>
# Azure UC configspup cost azure-config listpup cost azure-config get <account-id>pup cost azure-config create --file config.jsonpup cost azure-config delete <account-id>
# GCP usage cost configspup cost gcp-config listpup cost gcp-config get <account-id>pup cost gcp-config create --file config.jsonpup cost gcp-config delete <account-id>

Subcommand Discovery

bash
pup --version           # Confirm installed version before documenting workaroundspup --help              # List all commandspup <command> --help    # Command-specific helppup dashboards get <dashboard-id> --jq '{title, layout_type}'  # Filter output before formatting

If local help differs from this skill, compare pup --version with the latest stable release before inventing a workaround.

Error Handling

ErrorCauseFix
401 UnauthorizedToken expiredpup auth refresh
403 ForbiddenMissing scopeCheck app key permissions
404 Not FoundWrong ID/resourceVerify resource exists
Rate limitedToo many requestsAdd delays between calls

Install

See Setup Pup for installation instructions.

Verify Installation

bash
which puppup --version

Sites

SiteDD_SITE value
US1 (default)datadoghq.com
US3us3.datadoghq.com
US5us5.datadoghq.com
EU1datadoghq.eu
AP1ap1.datadoghq.com
AP2ap2.datadoghq.com
US1-FEDddog-gov.com

來源與署名

來源:datadog-labs/agent-skills位於dd-pup提交5b40c73

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架