Skip to main content
skill CX Codex

dd-audit-cost-spike-investigation — Claude Code skill: trace a cost

Correlates a Datadog usage spike with Audit Trail config changes, so you can see who changed what right before the bill jumped.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add datadog-labs/agent-skills --skill dd-audit-cost-spike-investigation -a claude-code
npx skills add datadog-labs/agent-skills --skill cost-spike-investigation -a claude-code
Open on GitHub

What dd-audit-cost-spike-investigation does

The skill follows one causal chain: someone changed a setting, that change raised data volume, usage spiked, cost went up. Usage Metering answers when and what; Audit Trail answers who. It starts by pulling hourly usage through the hourly_usage endpoint and pinning the hour or day where volume jumped.

Then it searches Audit Trail for created, modified and deleted events in the 24 hours before the spike, and narrows the results to the categories that touch the spiking product. For llm_observability that means integrations, APM and Log Management; for logs it means pipelines, indexes and exclusion filters. You get a report with the spike time, the candidate changes, the most likely cause and a confidence level.

Setup needs pup auth login, and Usage Metering queries also require DD_API_KEY, DD_APP_KEY and DD_SITE. The skill finds configuration changes, not the service that submitted the data — for per-submission attribution you need LLM Observability traces or APM instrumentation. When nothing matches, it suggests widening the window to 72 hours and checking deploys.

What it helps with

  • find which config edit inflated usage
  • separate a config-driven cost jump from organic traffic growth
  • line up the spike hour with the change history
  • write up findings for the team
  • decide whether to revert the change or update cost forecasts

Example prompts for the agent

  • Investigate why llm_observability usage grew over the last 7 days
  • Find config changes in the 24h before the logs cost spike
  • What changed right before indexed_spans jumped?

How to install dd-audit-cost-spike-investigation

1Skills CLI (Vercel)

npx skills add datadog-labs/agent-skills --skill dd-audit-cost-spike-investigation -a claude-code
npx skills add datadog-labs/agent-skills --skill cost-spike-investigation -a claude-code

2Manually: put the files in place

~/.claude/skills/cost-spike-investigation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cost-spike-investigation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about dd-audit-cost-spike-investigation

How do I install dd-audit-cost-spike-investigation in Claude?

Run npx skills add datadog-labs/agent-skills --skill dd-audit-cost-spike-investigation -a claude-code. The skill lands in ~/.claude/skills/cost-spike-investigation/SKILL.md.

What does dd-audit-cost-spike-investigation do?

It correlates Usage Metering data about a spike with Audit Trail config changes from the preceding window. The output names the likely cause and a confidence level.

What do I need before running the skill?

pup auth login plus DD_API_KEY, DD_APP_KEY and DD_SITE. It identifies configuration changes, not which service submitted the data.

Source text

SKILL.md · MIT
---
name: dd-audit-cost-spike-investigation
description: Investigate a Datadog product usage or cost spike by correlating Usage Metering data (when/what spiked) with Audit Trail config changes (who changed what in the preceding window).
metadata:
  version: "0.1.0"
  author: datadog-labs
  repository: https://github.com/datadog-labs/agent-skills
  tags: datadog,audit,cost,usage,spike,finops,dd-audit
  alwaysApply: "false"
---

# Audit Trail: Cost / Usage Spike Investigation

Identify what caused a Datadog usage spike by correlating billing data with configuration change history.

The causal chain is: **someone changed something → that change increased data volume → usage spiked → cost went up**. Usage Metering tells you when and what; Audit Trail tells you who made the change.

## Prerequisites

```bash
pup auth login   # OAuth2 (recommended) — covers audit queries
# Usage Metering queries also need DD_API_KEY + DD_APP_KEY
export DD_API_KEY=<your-api-key>
export DD_APP_KEY=<your-app-key>
export DD_SITE=datadoghq.com
```

## Scope Boundary

This skill identifies **configuration changes** that may have caused a spike. It does not identify which specific user or process *submitted* the data (e.g., which service sent the LLM spans). For per-submission attribution, use LLM Observability traces or APM instrumentation.

## Investigation Workflow

### Step 1 — Identify the spike window and product family

```bash
START=$(date -u -v-7d +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -d "7 days ago" +"%Y-%m-%dT%H:%M:%SZ")
END=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

curl -s -G "https://api.${DD_SITE}/api/v2/usage/hourly_usage" \
  -H "DD-API-KEY: ${DD_API_KEY}" \
  -H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
  --data-urlencode "filter[timestamp][start]=${START}" \
  --data-urlencode "filter[timestamp][end]=${END}" \
  --data-urlencode "filter[product_families]=all" \
  | jq '[.data[] | {
      timestamp: .attributes.timestamp,
      product: .attributes.product_family,
      measurements: [.attributes.measurements[] | {type: .usage_type, value: .value}]
    }]'
```

**Product families with LLM/AI coverage:** `llm_observability`, `bits_ai`, `logs`, `apm`

### Step 2 — Pinpoint the spike

From Step 1, identify the hour/day where volume jumped. Note the timestamp as `SPIKE_TIME`.

### Step 3 — Search Audit Trail for config changes in the 24h preceding the spike

```bash
pup audit-logs search \
  --query "@action:(created OR modified OR deleted)" \
  --from "SPIKE_TIME_MINUS_24H" \
  --to "SPIKE_TIME" \
  --limit 200 \
  -o json \
  | jq '[.data[] | {
      timestamp: .attributes.timestamp,
      user: .attributes.attributes.usr.email,
      actor_type: .attributes.attributes.evt.actor.type,
      action: .attributes.attributes.action,
      event_category: .attributes.attributes.evt.name,
      resource_type: .attributes.attributes.asset.type,
      resource_id: .attributes.attributes.asset.id
    }]'
```

> **Note:** `--from` and `--to` accept ISO timestamps (e.g., `2026-05-01T14:00:00Z`) or relative values (`1h`, `24h`, `7d`).

### Step 4 — Narrow to product-relevant config changes

Filter to the audit categories most likely to affect the spiking product:

| If this product spiked | Add to query |
|------------------------|-------------|
| `llm_observability` | `@evt.name:(Integration OR APM OR "Log Management")` |
| `logs` / `indexed_logs` | `@evt.name:"Log Management" @asset.type:(pipeline OR index OR exclusion_filter)` |
| `apm` / `indexed_spans` | `@evt.name:APM @asset.type:(retention_filter OR sampling_rate)` |
| `rum` | `@evt.name:RUM` |
| `metrics` | `@evt.name:Metrics` |

Example for LLM Observability spike:

```bash
pup audit-logs search \
  --query "@evt.name:(Integration OR APM OR \"Log Management\") @action:(created OR modified)" \
  --from "SPIKE_TIME_MINUS_24H" \
  --to "SPIKE_TIME" \
  --limit 100 \
  -o json \
  | jq '[.data[] | {
      timestamp: .attributes.timestamp,
      user: .attributes.attributes.usr.email,
      action: .attributes.attributes.action,
      category: .attributes.attributes.evt.name,
      resource_type: .attributes.attributes.asset.type,
      resource_id: .attributes.attributes.asset.id
    }]'
```

## Output Format

```
Usage spike detected:
  Product: <product_family>
  Spike time: <SPIKE_TIME>
  Volume: <baseline> → <spike_value> (<magnitude>×)

Configuration changes in 24h preceding spike:
  <timestamp> | <user_email> | <action> <resource_type> <resource_id> | <category>

Likely causal change: <most-proximate change matching the product family>

Confidence: HIGH (single clear change) / MEDIUM (multiple candidates) / LOW (no matching changes)

Next steps:
  - Confirm with <user_email> whether the change was intentional
  - If unintentional: revert <resource_id> and monitor volume
  - If intentional: update cost forecasts and alert thresholds
```

## When No Causal Change Is Found

1. The change may predate the 24h window — expand to 72h
2. The increase may be from application-side instrumentation changes — check deploys
3. The increase may be organic traffic growth — correlate with product launch or traffic event

## References

- [Usage Metering API](https://docs.datadoghq.com/api/latest/usage-metering/)
- [Audit Trail API](https://docs.datadoghq.com/api/latest/audit/)
- [LLM Observability](https://docs.datadoghq.com/llm_observability/)

© datadog-labs · MIT · datadog-labs/agent-skills

Similar skills

Everything for DevOps and infrastructure →

From the same set20

agent-observability-eval-pipeline Walks an instrumented ml_app through six phases: classify traces, root-cause failures, bootstrap evaluators, build a dataset, run an experiment, analyze it. CX Codex +1 540installs agent-observability-session-classify Evaluates user intent satisfaction in Datadog Agent Observability traces and sessions. Returns a compact yes, partial, or no verdict with a brief reason. CX Codex +1 529installs service-remapping A skill for building Datadog APM service remapping rules: collapse noisy inferred entities, clean up auto-generated names, handle renames. CX Codex +1 478installs dd-audit-compliance-report Pulls Datadog Audit Trail events into an auditor-ready report mapped to SOC 2 and PCI DSS controls. CX Codex +1 477installs upgrade-browser-sdk-v7 Walks a project through the Datadog Browser SDK jump from v6 to v7: stale options, CDN paths, changed APIs. Useful when the upgrade breaks init. CX Codex +1 459installs k9-ownership-byod-setup Builds a Datadog ownership preferences CSV and walks you through uploading it. Useful when the Ownership Agent guesses the wrong resource owners. CX Codex +1 454installs agent-observability-auto-experiment Runs a local improvement loop against real Datadog LLM-Obs data: baseline eval, one focused change, re-score, keep it if the score moves the right way. CX Codex +1 453installs dd-audit-ai-activity Reads the Datadog Audit Trail and shows which users called Datadog MCP tools, what those calls touched, and which events look off. CX Codex +1 433installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor