
Datadog Cli
- 556 installs
- 2.3k repo stars
- Updated March 5, 2026
- softaworks/agent-toolkit
datadog-cli is a Claude Code skill that exposes Datadog log, metric, trace, and dashboard CLI commands for developers who need live production observability data inside the coding agent.
About
datadog-cli is an agent-toolkit skill that teaches coding agents to debug and triage using Datadog through a structured CLI workflow. Before any command, agents must read bundled reference docs for log commands, metrics, query syntax, workflows, and dashboards. Setup requires DD_API_KEY and related Datadog environment variables. Developers reach for datadog-cli when investigating production errors, correlating traces with log lines, or pulling dashboard context during incident response without switching to the Datadog web UI. The skill maps common observability tasks—log search, metric queries, request tracing—to documented command patterns agents can run from the terminal.
- Search, tail, and compare production logs with advanced filters and pattern detection
- Query metrics, run aggregations, and inspect distributed traces in a single CLI
- Supports parallel multi-queries, context lookup before/after timestamps, and real-time streaming
- Works with any Datadog site via --site flag and requires only API + APP keys
- Includes mandatory reference docs for logs, metrics, query syntax, workflows and dashboards
Datadog Cli by the numbers
- 556 all-time installs (skills.sh)
- +14 installs in the week ending Jul 27, 2026 (Skillselion tracking)
- Ranked #358 of 1,039 Cloud & Infrastructure skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/softaworks/agent-toolkit --skill datadog-cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 556 |
|---|---|
| repo stars | ★ 2.3k |
| Last updated | March 5, 2026 |
| Repository | softaworks/agent-toolkit ↗ |
How do coding agents query Datadog logs and metrics?
Let their coding agent query live logs, metrics, traces and dashboards directly from Datadog without leaving the IDE.
Who is it for?
Developers debugging production incidents who already use Datadog and want agents to run observability queries from the terminal.
Skip if: Teams without Datadog accounts or workflows that only need local unit-test debugging without production telemetry.
When should I use this skill?
A developer asks to search Datadog logs, query metrics, trace requests, or inspect dashboards during production debugging.
What you get
Log search results, metric time series, trace spans, and dashboard context pulled via CLI command output.
- Log query results
- Metric and trace outputs
Files
Datadog CLI
A CLI tool for AI agents to debug and triage using Datadog logs and metrics.
Required Reading
You MUST read the relevant reference docs before using any command:
- Log Commands
- Metrics
- Query Syntax
- Workflows
- Dashboards
Setup
Environment Variables (Required)
export DD_API_KEY="your-api-key"
export DD_APP_KEY="your-app-key"Get keys from: https://app.datadoghq.com/organization-settings/api-keys
Running the CLI
npx @leoflores/datadog-cli <command>For non-US Datadog sites, use --site flag:
npx @leoflores/datadog-cli logs search --query "*" --site datadoghq.euCommands Overview
| Command | Description |
|---|---|
logs search | Search logs with filters |
logs tail | Stream logs in real-time |
logs trace | Find logs for a distributed trace |
logs context | Get logs before/after a timestamp |
logs patterns | Group similar log messages |
logs compare | Compare log counts between periods |
logs multi | Run multiple queries in parallel |
logs agg | Aggregate logs by facet |
metrics query | Query timeseries metrics |
errors | Quick error summary by service/type |
services | List services with log activity |
dashboards | Manage dashboards (CRUD) |
dashboard-lists | Manage dashboard lists |
Quick Examples
Search Errors
npx @leoflores/datadog-cli logs search --query "status:error" --from 1h --prettyTail Logs (Real-time)
npx @leoflores/datadog-cli logs tail --query "service:api status:error" --prettyError Summary
npx @leoflores/datadog-cli errors --from 1h --prettyTrace Correlation
npx @leoflores/datadog-cli logs trace --id "abc123def456" --prettyQuery Metrics
npx @leoflores/datadog-cli metrics query --query "avg:system.cpu.user{*}" --from 1h --prettyCompare Periods
npx @leoflores/datadog-cli logs compare --query "status:error" --period 1h --prettyGlobal Flags
| Flag | Description |
|---|---|
--pretty | Human-readable output with colors |
--output <file> | Export results to JSON file |
--site <site> | Datadog site (e.g., datadoghq.eu) |
Time Formats
- Relative:
30m,1h,6h,24h,7d - ISO 8601:
2024-01-15T10:30:00Z
Incident Triage Workflow
# 1. Quick error overview
npx @leoflores/datadog-cli errors --from 1h --pretty
# 2. Is this new? Compare to previous period
npx @leoflores/datadog-cli logs compare --query "status:error" --period 1h --pretty
# 3. Find error patterns
npx @leoflores/datadog-cli logs patterns --query "status:error" --from 1h --pretty
# 4. Narrow down by service
npx @leoflores/datadog-cli logs search --query "status:error service:api" --from 1h --pretty
# 5. Get context around a timestamp
npx @leoflores/datadog-cli logs context --timestamp "2024-01-15T10:30:00Z" --service api --pretty
# 6. Follow the distributed trace
npx @leoflores/datadog-cli logs trace --id "TRACE_ID" --prettySee workflows.md for more debugging workflows.
datadog Plugin
A Claude Code skill for debugging and triaging with Datadog logs, metrics, and dashboards.
What it does
This skill enables Claude to use the datadog CLI for:
- Log search - Query and filter logs with Datadog syntax
- Real-time tailing - Stream logs as they arrive
- Trace analysis - Follow distributed requests across services
- Pattern detection - Group similar log messages automatically
- Metrics query - Query timeseries metrics with PromQL-style syntax
- Dashboard management - List, create, update, and delete dashboards
Prerequisites
1. Install the CLI from leonardocouy/datadog-cli
2. Set environment variables:
export DD_API_KEY="your-api-key"
export DD_APP_KEY="your-app-key"Get keys from: https://app.datadoghq.com/organization-settings/api-keys
Installation
/plugin marketplace add leonardocouy/cc-datadog
/plugin install datadog@cc-datadogUsage
Once installed, Claude will automatically use datadog commands when you ask questions like:
- "Search for error logs in the last hour"
- "Tail logs from the payments service"
- "Trace this request ID across services"
- "Show me error patterns from today"
- "What dashboards do we have?"
- "Please explain this Datadog dashboard https://app.datadoghq.com/dashboard/xxx-xxx-xxx"
- "Create a new Datadog dashboard for the metrics cpu.usage, memory.used"
Commands Reference
| Command | Purpose |
|---|---|
datadog logs search | Search and filter logs |
datadog logs tail | Stream logs in real-time |
datadog logs trace | Find logs for a trace ID |
datadog logs patterns | Group similar log messages |
datadog logs compare | Compare current vs previous period |
datadog logs context | Get logs around a timestamp |
datadog logs agg | Aggregate logs by facet |
datadog logs multi | Run multiple queries in parallel |
datadog metrics query | Query timeseries metrics |
datadog dashboards list | List dashboards |
datadog dashboards get | Get dashboard definition |
datadog dashboards create | Create a dashboard |
datadog dashboards update | Update a dashboard |
datadog dashboards delete | Delete a dashboard |
datadog errors | Quick error summary |
datadog services | List services with log activity |
See the datadog-cli repository for complete command documentation.
License
MIT
Dashboards Reference
⚠️ CRITICAL: Dashboard Update is DESTRUCTIVE
The `dashboards update` command REPLACES the entire dashboard, not just the fields you specify.
If you omit any of these fields during an update, they will be permanently deleted:
--template-variables→ Template variables will be removed--description→ Description will be cleared--notify-list→ Notify list will be cleared
Example of DATA LOSS:
# This will DELETE template variables and description!
npx @leoflores/datadog-cli dashboards update \
--id "abc-def-ghi" \
--title "My Dashboard" \
--layout ordered \
--widgets '[...]' # Only widgets provided, other fields wiped!Safe Dashboard Update Workflow
ALWAYS follow this 3-step process when updating dashboards:
⚠️ Important: Always use--outputto save to a temp file instead of capturing output in a bash variable. JSON with special characters, newlines, or ANSI codes can breakjqparsing when piped throughecho.
Step 1: Backup the Current Dashboard to a Temp File
# Save the current dashboard state BEFORE any changes
# Using --output ensures clean JSON without encoding issues
npx @leoflores/datadog-cli dashboards get --id "abc-def-ghi" --output /tmp/dashboard.jsonStep 2: Modify and Preserve All Fields
# Extract existing values directly from the file (not through echo!)
TEMPLATE_VARS=$(jq -c '.dashboard.templateVariables // []' /tmp/dashboard.json)
DESCRIPTION=$(jq -r '.dashboard.description // ""' /tmp/dashboard.json)
# Modify widgets (example: change title of widget at index 1)
WIDGETS=$(jq -c '.dashboard.widgets | .[1].definition.title = "New Title"' /tmp/dashboard.json)
# Update with ALL fields preserved
npx @leoflores/datadog-cli dashboards update \
--id "abc-def-ghi" \
--title "My Dashboard" \
--layout ordered \
--widgets "$WIDGETS" \
--description "$DESCRIPTION" \
--template-variables "$TEMPLATE_VARS" \
--prettyStep 3: Verify the Update
# Confirm all fields are intact
npx @leoflores/datadog-cli dashboards get --id "abc-def-ghi" --prettyRecovery from Accidental Data Loss
# If you have a backup file, restore from it
WIDGETS=$(jq -c '.dashboard.widgets' /tmp/dashboard.json)
TEMPLATE_VARS=$(jq -c '.dashboard.templateVariables // []' /tmp/dashboard.json)
DESCRIPTION=$(jq -r '.dashboard.description // ""' /tmp/dashboard.json)
TITLE=$(jq -r '.dashboard.title' /tmp/dashboard.json)
LAYOUT=$(jq -r '.dashboard.layoutType' /tmp/dashboard.json)
npx @leoflores/datadog-cli dashboards update \
--id "abc-def-ghi" \
--title "$TITLE" \
--layout "$LAYOUT" \
--widgets "$WIDGETS" \
--description "$DESCRIPTION" \
--template-variables "$TEMPLATE_VARS" \
--prettyWhy Use Files Instead of Variables?
❌ Don't do this - prone to parsing errors:
DASHBOARD_JSON=$(npx @leoflores/datadog-cli dashboards get --id "abc-def-ghi")
WIDGETS=$(echo "$DASHBOARD_JSON" | jq -c '.dashboard.widgets') # May fail!✅ Do this - reliable with any JSON content:
npx @leoflores/datadog-cli dashboards get --id "abc-def-ghi" --output /tmp/dashboard.json
WIDGETS=$(jq -c '.dashboard.widgets' /tmp/dashboard.json) # Always worksCommands Overview
| Command | Description |
|---|---|
dashboards list | List all dashboards |
dashboards get | Get full dashboard definition |
dashboards create | Create a new dashboard |
dashboards update | ⚠️ DESTRUCTIVE - Replaces entire dashboard |
dashboards delete | Delete a dashboard |
dashboard-lists list | List all dashboard lists |
dashboard-lists get | Get dashboard list details |
dashboard-lists create | Create a new list |
dashboard-lists update | Update list name |
dashboard-lists delete | Delete a list |
dashboard-lists items | List dashboards in a list |
dashboard-lists add-items | Add dashboards to list |
dashboard-lists delete-items | Remove dashboards from list |
Dashboard Flags
| Flag | Commands | Description |
|---|---|---|
--id | get, update, delete | Dashboard ID |
--title | create, update | Dashboard title |
--layout | create, update | ordered or free |
--widgets | create, update | Widgets JSON (or stdin) |
--description | create, update | ⚠️ Required on update to preserve |
--template-variables | create, update | ⚠️ Required on update to preserve |
--notify-list | create, update | ⚠️ Required on update to preserve |
--read-only | create, update | Make read-only |
Examples
List & Get
npx @leoflores/datadog-cli dashboards list --pretty
npx @leoflores/datadog-cli dashboards get --id "abc-def-ghi" --prettyCreate Dashboard
npx @leoflores/datadog-cli dashboards create \
--title "API Monitoring" \
--layout ordered \
--widgets '[{"definition":{"type":"timeseries","requests":[{"q":"avg:system.cpu.user{*}"}]}}]' \
--prettyWith Template Variables
npx @leoflores/datadog-cli dashboards create \
--title "Service Dashboard" \
--layout ordered \
--template-variables '[{"name":"env","prefix":"env","default":"prod"},{"name":"service","prefix":"service","default":"*"}]' \
--widgets '[{"definition":{"type":"timeseries","requests":[{"q":"avg:system.cpu.user{$env,$service}"}]}}]' \
--prettyUsing Stdin
cat widgets.json | npx @leoflores/datadog-cli dashboards create --title "My Dashboard" --layout ordered --prettyTemplate Variables
{"name": "env", "prefix": "env", "default": "prod"}Use in queries: avg:system.cpu.user{$env,$service}
Widget Types
Timeseries
{"definition": {"type": "timeseries", "title": "CPU", "requests": [{"q": "avg:system.cpu.user{*}"}]}}Query Value
{"definition": {"type": "query_value", "title": "Errors", "requests": [{"q": "sum:errors{*}.as_count()"}]}}Top List
{"definition": {"type": "toplist", "title": "Top Services", "requests": [{"q": "top(sum:errors{*} by {service}, 10, 'sum', 'desc')"}]}}Layout Types
- ordered: Auto-arranged responsive grid
- free: Manual positioning with x, y, width, height
Dashboard Lists
# List all
npx @leoflores/datadog-cli dashboard-lists list --pretty
# Add dashboards to list
npx @leoflores/datadog-cli dashboard-lists add-items --id 123 \
--dashboards '[{"type":"custom_timeboard","id":"abc-def-ghi"}]' --prettyLog Commands Reference
logs search
Search logs with filters.
npx @leoflores/datadog-cli logs search --query "<query>" [--from <time>] [--to <time>] [--limit <n>] [--sort <order>]| Flag | Default | Description |
|---|---|---|
--query | * | Datadog search query |
--from | 15m | Start time |
--to | now | End time |
--limit | 100 | Max results (max: 1000) |
--sort | -timestamp | Sort order |
npx @leoflores/datadog-cli logs search --query "service:api status:error" --from 1h --prettylogs tail
Stream logs in real-time. Press Ctrl+C to stop.
npx @leoflores/datadog-cli logs tail --query "<query>" [--interval <seconds>]| Flag | Default | Description |
|---|---|---|
--interval | 2 | Polling interval in seconds |
npx @leoflores/datadog-cli logs tail --query "status:error" --prettylogs trace
Find all logs for a distributed trace across services.
npx @leoflores/datadog-cli logs trace --id "<trace-id>" [--from <time>] [--to <time>]Searches both @trace_id and @dd.trace_id attributes.
npx @leoflores/datadog-cli logs trace --id "abc123def456" --from 24h --prettylogs context
Get logs before and after a specific timestamp.
npx @leoflores/datadog-cli logs context --timestamp "<iso-timestamp>" [--before <time>] [--after <time>] [--service <svc>]| Flag | Default | Description |
|---|---|---|
--before | 5m | Time window before |
--after | 5m | Time window after |
--service | - | Filter by service |
npx @leoflores/datadog-cli logs context --timestamp "2024-01-15T10:30:00Z" --service api --before 5m --after 2m --prettylogs patterns
Group similar log messages to find patterns. Replaces UUIDs, numbers, IPs, etc.
npx @leoflores/datadog-cli logs patterns --query "<query>" [--from <time>] [--limit <n>]Returns top 50 patterns with counts and sample messages.
npx @leoflores/datadog-cli logs patterns --query "status:error" --from 1h --prettylogs compare
Compare log counts between current period and previous period.
npx @leoflores/datadog-cli logs compare --query "<query>" --period <time>Shows absolute and percentage change with directional arrows.
npx @leoflores/datadog-cli logs compare --query "status:error" --period 1h --prettylogs multi
Run multiple queries in parallel.
npx @leoflores/datadog-cli logs multi --queries "name1:query1,name2:query2" [--from <time>]npx @leoflores/datadog-cli logs multi --queries "errors:status:error,warnings:status:warn" --from 1h --prettylogs agg
Aggregate logs by facet.
npx @leoflores/datadog-cli logs agg --query "<query>" --facet <facet> [--from <time>]Common facets: status, service, host, @http.status_code, @error.kind
npx @leoflores/datadog-cli logs agg --query "*" --facet status --from 1h --prettyMetrics Reference
metrics query
Query timeseries metrics from Datadog.
npx @leoflores/datadog-cli metrics query --query "<metrics-query>" [--from <time>] [--to <time>]| Flag | Default | Description |
|---|---|---|
--query | required | Metrics query |
--from | 15m | Start time |
--to | now | End time |
Query Format
<aggregation>:<metric>{<tags>}Aggregations: avg, sum, min, max, count
Examples
System Metrics
npx @leoflores/datadog-cli metrics query --query "avg:system.cpu.user{*}" --from 1h --pretty
npx @leoflores/datadog-cli metrics query --query "avg:system.mem.used{*}" --from 1h --prettyService-Specific
npx @leoflores/datadog-cli metrics query --query "avg:system.cpu.user{service:api}" --from 1h --prettyAPM Metrics
npx @leoflores/datadog-cli metrics query --query "sum:trace.http.request.errors{service:api}.as_count()" --from 1h --pretty
npx @leoflores/datadog-cli metrics query --query "p99:trace.http.request.duration{service:api}" --from 1h --prettyWith Tags
npx @leoflores/datadog-cli metrics query --query "avg:system.cpu.user{env:prod,service:api}" --from 1h --prettyOutput
Returns series with:
- Metric name and scope
- Point list (timestamp/value pairs)
- Tags
- Latest value + min/max/avg stats
Datadog Query Syntax
Operators
| Operator | Example | Description |
|---|---|---|
AND | service:api status:error | Both conditions (implicit) |
OR | status:error OR status:warn | Either condition |
- | -status:info | Exclude |
* | service:api-* | Wildcard |
>= <= | @http.status_code:>=400 | Numeric comparison |
[TO] | @duration:[1000 TO 5000] | Range |
Common Attributes
| Attribute | Description |
|---|---|
service | Service name |
status | Log level (error, warn, info, debug) |
host | Hostname |
@http.status_code | HTTP status code |
@http.method | HTTP method |
@http.url | Request URL |
@error.kind | Error type |
@error.message | Error message |
@trace_id | Trace ID |
@dd.trace_id | Datadog trace ID |
Time Formats
Relative
1m- 1 minute30m- 30 minutes1h- 1 hour6h- 6 hours24h- 24 hours7d- 7 days
Absolute
- ISO 8601:
2024-01-15T10:30:00Z
Example Queries
# All errors
status:error
# Errors in specific service
service:api status:error
# 5xx HTTP errors
@http.status_code:>=500
# Exclude info logs
-status:info
# Multiple services
service:api OR service:payment
# Timeout errors
error:timeout OR @error.kind:TimeoutError
# Slow requests (>1s)
@duration:>=1000Common Workflows
Incident Triage
Step-by-step workflow for investigating production issues.
# 1. Quick error overview
npx @leoflores/datadog-cli errors --from 1h --pretty
# 2. Is this new? Compare to previous period
npx @leoflores/datadog-cli logs compare --query "status:error" --period 1h --pretty
# 3. Find error patterns
npx @leoflores/datadog-cli logs patterns --query "status:error" --from 1h --pretty
# 4. Narrow down by service
npx @leoflores/datadog-cli logs search --query "status:error service:payment-api" --from 1h --pretty
# 5. Get context around a specific timestamp
npx @leoflores/datadog-cli logs context --timestamp "2024-01-15T10:30:00Z" --service api --before 5m --after 2m --pretty
# 6. Follow the distributed trace
npx @leoflores/datadog-cli logs trace --id "TRACE_ID" --prettyReal-time Debugging
Monitor logs as they arrive.
# Stream all errors
npx @leoflores/datadog-cli logs tail --query "status:error" --pretty
# Watch specific service
npx @leoflores/datadog-cli logs tail --query "service:api status:error" --pretty
# Monitor deployments
npx @leoflores/datadog-cli logs tail --query "service:deploy" --prettyService Health Check
Assess overall service health.
# List all services
npx @leoflores/datadog-cli services --from 24h --pretty
# Check error distribution for a service
npx @leoflores/datadog-cli logs agg --query "service:api" --facet status --from 1h --pretty
# Check CPU/memory usage
npx @leoflores/datadog-cli metrics query --query "avg:system.cpu.user{service:api}" --from 1h --pretty
npx @leoflores/datadog-cli metrics query --query "avg:system.mem.used{service:api}" --from 1h --pretty
# Error summary for service
npx @leoflores/datadog-cli errors --service api --from 24h --prettyExport for Sharing
Save results to files for reports or sharing.
# Save search results
npx @leoflores/datadog-cli logs search --query "status:error" --from 1h --output errors.json --pretty
# Save error summary
npx @leoflores/datadog-cli errors --from 24h --output error-report.json --pretty
# Save metrics data
npx @leoflores/datadog-cli metrics query --query "avg:system.cpu.user{*}" --from 24h --output cpu-metrics.json --prettyMulti-Query Investigation
Run parallel queries for comprehensive view.
# Compare error types across services
npx @leoflores/datadog-cli logs multi \
--queries "api-errors:service:api status:error,payment-errors:service:payment status:error,auth-errors:service:auth status:error" \
--from 1h --pretty⚠️ Safe Dashboard Update
CRITICAL: Dashboard updates are destructive and replace the entire dashboard.
Follow the Safe Dashboard Update Workflow in dashboards.md to avoid data loss.
Related skills
How it compares
Use datadog-cli when production telemetry already lives in Datadog; use local log tailing skills for pre-deploy debugging only.
FAQ
What credentials does datadog-cli require?
datadog-cli requires Datadog environment variables including DD_API_KEY before agents run log, metric, or trace commands. Reference docs under references/ define setup and per-command syntax.
Which Datadog surfaces does datadog-cli cover?
datadog-cli covers log search, metrics queries, request tracing, and dashboard management. Agents must read logs-commands.md, metrics.md, query-syntax.md, workflows.md, and dashboards.md first.