Datadog

From G1Joshi/Agent-Skills · View interactive version

Datadog is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert Datadog monitoring assistance covering APM tracing, custom metrics, log collection, dashboards, and monitors. Use when instrumenting production infrastructure and observability.

How to use this skill

Skill file

Datadog

Datadog is a unified SaaS observability and security platform providing full-stack APM tracing, infrastructure monitoring, log aggregation, and real-time anomaly detection.

When to Use

Quick Start

1. Install Datadog Agent (Linux/macOS)

DD_API_KEY="<YOUR_DATADOG_API_KEY>" DD_SITE="datadoghq.com" \
  bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"

2. Auto-Instrument Node.js Application

npm install dd-trace --save
// At the absolute top of your entrypoint file (index.js)
import tracer from "dd-trace";
tracer.init({
  service: "order-service",
  env: "production",
  logInjection: true,
  runtimeMetrics: true,
});

Core Concepts

Auto-Instrumenting Applications with dd-trace

Adding distributed tracing to a Node.js microservice:

// Must be initialized before any other module imports!
import tracer from "dd-trace";

tracer.init({
  env: "production",
  service: "order-processing-service",
  version: "2026.1.0",
  logInjection: true, // Automatically inject trace IDs into logs
  runtimeMetrics: true, // Collect GC and event loop latency metrics
});

export default tracer;

Custom Business Metrics & StatsD

Submitting custom business KPIs with high performance over UDP:

from datadog import initialize, statsd

initialize(statsd_host="127.0.0.1", statsd_port=8125)

# Increment transaction counter with tags
statsd.increment(
    'ecommerce.checkout.success',
    tags=['payment_method:apple_pay', 'region:us_east']
)

# Record latency histogram
statsd.histogram(
    'ecommerce.checkout.duration_ms',
    value=245.5,
    tags=['tier:premium']
)

Correlating Logs with Distributed Traces

Formatting structured logs with active Datadog trace context:

{
  "timestamp": "2026-03-27T10:15:30.123Z",
  "level": "error",
  "message": "Payment authorization timed out with gateway",
  "dd": {
    "trace_id": "847291038472918374",
    "span_id": "1928374650192834",
    "service": "order-processing-service",
    "version": "2026.1.0",
    "env": "production"
  }
}

Common Patterns

Distributed APM Tracing with Custom Spans

Problem: Pinpointing exact latency bottlenecks within deeply nested asynchronous service methods.

Solution:

Wrap business logic in custom Datadog tracer spans:

import tracer from "dd-trace";
tracer.init(); // Initialize tracer before importing other packages

async function processOrder(orderId) {
  return tracer.trace(
    "order.process",
    { resource: "checkout" },
    async (span) => {
      span.setTag("order.id", orderId);

      const inventory = await checkInventory(orderId);
      span.setTag("inventory.status", inventory.status);

      const charge = await chargeCard(orderId);
      return { inventory, charge };
    },
  );
}

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| :------------------------------------------------------ | :--------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------- |

| Datadog Agent: API Key invalid | DD_API_KEY contains typo or belongs to wrong Datadog site (e.g. EU vs US). | Verify API key and ensure DD_SITE is configured correctly (datadoghq.com vs datadoghq.eu). |

| Traces not showing in APM dashboard | Application tracer unable to reach Datadog agent on port 8126. | Set DD_AGENT_HOST=127.0.0.1 and verify agent container port mapping. |

| Too many metrics: Custom metric cardinality explosion | Using dynamic UUIDs or timestamps as custom metric tag values. | Move high-cardinality values from metric tags to log attributes. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.