Labsco
DataDog logo

dd-code-generation

โ˜… 940

by datadog-labs ยท part of datadog-labs/pup

Use pup CLI for immediate Datadog operations or generate code for integration into applications

๐Ÿ”Œ This skill ships inside the pup plugin โ€” install the plugin and you also get 40 sub-agents.

This is the playbook your agent receives when the skill activates โ€” you don't need to read it to use the skill, but it's here to audit before installing.

Datadog Integration Skill

This skill helps users interact with Datadog through two complementary approaches:

  1. Immediate execution using the pup CLI tool
  2. Code generation for application integration using Datadog API clients

When to Use This Skill

Use this skill when the user:

  • Wants to query Datadog data (logs, traces, metrics, etc.)
  • Needs to configure Datadog (monitors, dashboards, SLOs, etc.)
  • Asks to "generate code" for a Datadog operation
  • Wants to integrate Datadog operations into their application
  • Needs examples of using Datadog API clients in a specific language

Pup CLI Tool

The pup CLI is a command-line wrapper for Datadog APIs written in Rust. It provides:

  • OAuth2 authentication (preferred) or API key authentication
  • 28 command groups covering 33+ API domains
  • JSON, YAML, and table output formats
  • 200+ subcommands for comprehensive Datadog operations

Pup Authentication

# OAuth2 (preferred)
pup auth login

# API Keys (fallback)
export DD_API_KEY="your-api-key"
export DD_APP_KEY="your-app-key"
export DD_SITE="datadoghq.com"

Pup Command Structure

pup <domain> <action> [options]
pup <domain> <subgroup> <action> [options]

# Examples
pup monitors list --tags="env:prod"
pup logs search --query="status:error" --from="1h"
pup metrics query --query="avg:system.cpu.user{*}" --from="1h"

Supported Operations

Core Observability

  • Metrics: Query, list, search, submit metrics
  • Logs: Search and aggregate log data
  • Traces: Query APM traces and spans
  • Events: List and search events
  • RUM: Real user monitoring data

Monitoring & Alerting

  • Monitors: Full CRUD operations
  • Dashboards: Create, list, get, delete
  • SLOs: Service level objectives management
  • Synthetics: Synthetic test management
  • Downtimes: Monitor downtime management
  • Notebooks: Investigation notebooks

Security & Compliance

  • Security Monitoring: Rules, signals, findings
  • Vulnerabilities: Security vulnerability scanning
  • Static Analysis: Code security analysis
  • Audit Logs: Organizational audit trail
  • Data Governance: Sensitive data scanning

Infrastructure & Cloud

  • Infrastructure: Host inventory and metrics
  • Tags: Resource tagging
  • Cloud Integrations: AWS, GCP, Azure

Incident & Operations

  • Incidents: Incident management
  • On-Call: On-call team management
  • Error Tracking: Application error tracking
  • Service Catalog: Service registry
  • Scorecards: Service quality metrics

Organization & Access

  • Users: User and role management
  • Organizations: Org settings
  • API Keys: API key management

See pup --help for complete command reference.

Example Interactions

Example 1: Quick Metrics Query

User: "Show me CPU usage for the last hour"

Response:

# Execute pup command for immediate results
pup metrics query --query="avg:system.cpu.user{*}" --from="1h" --to="now" --output=table

Example 2: Code Generation for Application

User: "Generate Python code to query error logs"

Response:

Here's Python code to query error logs using the Datadog API client:

[Provide Python code example using datadog-api-client]

To use this code:
1. Save to a file: `query_logs.py`
2. Install: `pip install datadog-api-client`
3. Set environment variables: `export DD_API_KEY="..." DD_APP_KEY="..."`
4. Run: `python query_logs.py`

For immediate results without writing code, you can also use:
pup logs search --query="status:error" --from="1h"

Example 3: Monitor Management

User: "List all production monitors"

Response:

# Using pup CLI
pup monitors list --tags="env:production" --output=table

# Or generate code for your application (specify language: typescript, python, java, go, rust)

When to Use Each Approach

Use Pup CLI When:

  • User wants immediate results
  • Exploring/experimenting with Datadog
  • One-off queries or operations
  • Quick troubleshooting
  • Testing queries before coding

Generate Code When:

  • User asks to "generate code" or "create a script"
  • Integrating into an application
  • Automating recurring operations
  • Building custom tools or dashboards
  • User specifies a programming language

Best Practices

  1. Start with pup for exploration: Use pup to test queries before generating code
  2. Match the user's language: If they mention TypeScript, Python, Java, Go, or Rust, use that language
  3. Provide complete examples: Include imports, error handling, and configuration
  4. Explain authentication: Always mention DD_API_KEY, DD_APP_KEY, DD_SITE
  5. Security reminders: Warn about not committing credentials to version control
  6. Show both approaches: Mention pup for quick testing + code for integration

Integration with Agents

This skill works with all 46 domain agents in the plugin:

  • Each agent describes Datadog functionality (logs, traces, metrics, monitors, etc.)
  • Use pup commands that match the agent's domain
  • Generate code using the corresponding Datadog API client methods

Common User Phrases

  • "Query [logs/metrics/traces]"
  • "Generate code to..."
  • "Show me [data type]"
  • "Create a [monitor/dashboard/SLO]"
  • "Write a [Python/TypeScript/Java/Go/Rust] script that..."
  • "I need a script to..."
  • "How do I integrate Datadog with..."

Resources