> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentcat.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Datadog

> Integrate AgentCat with your Datadog observability stack.

## Overview

Integrate AgentCat with Datadog for monitoring and alerting. Events are sent as both logs and metrics for comprehensive observability.

## Prerequisites

1. A Datadog account with an API key
2. Your Datadog site (e.g., `datadoghq.com` for US, `datadoghq.eu` for EU)

## Configuration

<CodeGroup>
  ```typescript TypeScript theme={null}
  agentcat.track(server, null, {
    exporters: {
      datadog: {
        type: "datadog",
        apiKey: process.env.DD_API_KEY,
        site: "datadoghq.com",
        service: "my-mcp-server",
        env: "production"
      }
    }
  })
  ```

  ```python Python theme={null}
  agentcat.track(server, None, agentcat.AgentCatOptions(
    exporters={
      "datadog": {
        "type": "datadog",
        "api_key": os.getenv("DD_API_KEY"),
        "site": "datadoghq.com",
        "service": "my-mcp-server",
        "env": "production"
      }
    }
  ))
  ```

  ```go Go theme={null}
  mcpcat.Track(s, "", &mcpcat.Options{
      Exporters: map[string]any{
          "datadog": map[string]any{
              "type":    "datadog",
              "apiKey":  os.Getenv("DD_API_KEY"),
              "site":    "datadoghq.com",
              "service": "my-mcp-server",
              "env":     "production",
          },
      },
  })
  ```
</CodeGroup>

## Configuration Fields

| Field                | Type   | Required | Description                                          |
| -------------------- | ------ | -------- | ---------------------------------------------------- |
| `api_key` / `apiKey` | string | Yes      | Your Datadog API key                                 |
| `site`               | string | Yes      | Datadog site (e.g., "datadoghq.com", "datadoghq.eu") |
| `service`            | string | Yes      | Service name for grouping                            |
| `env`                | string | No       | Environment name (default: "production")             |

## Field Mapping

### Trace and Span IDs

| AgentCat Field | Datadog Field | Format                                |
| -------------- | ------------- | ------------------------------------- |
| `session_id`   | `trace_id`    | Numeric - last 64 bits of SHA256 hash |
| `event_id`     | `span_id`     | Numeric - SHA256 hash                 |

### Logs

Each event creates a log entry with the following structure:

| Field       | Value                              | Description                                                          |
| ----------- | ---------------------------------- | -------------------------------------------------------------------- |
| `message`   | `"{event_type} - {resource_name}"` | Combined event type and resource (e.g., "tools/call - get\_weather") |
| `service`   | Your configured service name       | From exporter configuration                                          |
| `ddsource`  | `"agentcat"`                       | Fixed source identifier                                              |
| `ddtags`    | Comma-separated string             | Includes `env`, `event_type`, `resource`, and `error` tags           |
| `timestamp` | Unix timestamp in milliseconds     | Event occurrence time                                                |
| `status`    | `"error"` or `"info"`              | Based on `is_error` flag                                             |

#### MCP Event Data

All AgentCat event fields are preserved in the `mcp` object:

| Field                | Description                     |
| -------------------- | ------------------------------- |
| `mcp.session_id`     | Session identifier              |
| `mcp.event_id`       | Event identifier                |
| `mcp.event_type`     | Event type (e.g., "tools/call") |
| `mcp.resource`       | Resource name                   |
| `mcp.duration_ms`    | Duration in milliseconds        |
| `mcp.user_intent`    | User's intent (if captured)     |
| `mcp.actor_id`       | User identifier (if identified) |
| `mcp.actor_name`     | User name (if identified)       |
| `mcp.client_name`    | MCP client name                 |
| `mcp.client_version` | MCP client version              |
| `mcp.server_name`    | Server name                     |
| `mcp.server_version` | Server version                  |
| `mcp.is_error`       | Error flag (boolean)            |
| `mcp.error`          | Error details (if applicable)   |

### Metrics

| Metric Name          | Type  | Description                    |
| -------------------- | ----- | ------------------------------ |
| `mcp.events.count`   | count | Total number of events         |
| `mcp.event.duration` | gauge | Event duration in milliseconds |
| `mcp.errors.count`   | count | Number of error events         |

All metrics include the following tags for filtering and grouping:

| Tag          | Example Value     | Source                                  |
| ------------ | ----------------- | --------------------------------------- |
| `service`    | `"my-mcp-server"` | Exporter configuration                  |
| `env`        | `"production"`    | Exporter configuration                  |
| `event_type` | `"tools.call"`    | Event type (slashes replaced with dots) |
| `resource`   | `"get_weather"`   | Resource name                           |
