Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ You need valid Datadog API credentials to use this MCP server:
- `DATADOG_APP_KEY`: Your Datadog Application key
- `DATADOG_SITE` (optional): The Datadog site (e.g. `datadoghq.eu`)
- `DATADOG_SUBDOMAIN` (optional): The Datadog subdomain (e.g. `<your-subdomain>.datadoghq.com`)
- `DATADOG_STORAGE_TIER` (optional): Logs storage tier for v2 logs searches. Supported values: `indexes`, `online-archives`, or `flex`. Use `flex` for non-prod SAAS environments where logs are stored in the Flex tier.

Export them in your environment before running the server:

Expand All @@ -221,6 +222,7 @@ export DATADOG_API_KEY="your_api_key"
export DATADOG_APP_KEY="your_app_key"
export DATADOG_SITE="your_datadog_site" # Optional
export DATADOG_SUBDOMAIN="your_datadog_subdomain" # Optional
export DATADOG_STORAGE_TIER="flex" # Optional: indexes | online-archives | flex
```

## Installation
Expand Down Expand Up @@ -271,7 +273,8 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
"DATADOG_API_KEY": "<YOUR_API_KEY>",
"DATADOG_APP_KEY": "<YOUR_APP_KEY>",
"DATADOG_SITE": "<YOUR_SITE>", // Optional
"DATADOG_SUBDOMAIN": "<YOUR_SUBDOMAIN>" // Optional
"DATADOG_SUBDOMAIN": "<YOUR_SUBDOMAIN>", // Optional
"DATADOG_STORAGE_TIER": "indexes" // Optional: indexes | online-archives | flex
}
}
}
Expand All @@ -290,7 +293,8 @@ Or specify via `npx`:
"DATADOG_API_KEY": "<YOUR_API_KEY>",
"DATADOG_APP_KEY": "<YOUR_APP_KEY>",
"DATADOG_SITE": "<YOUR_SITE>", // Optional
"DATADOG_SUBDOMAIN": "<YOUR_SUBDOMAIN>" // Optional
"DATADOG_SUBDOMAIN": "<YOUR_SUBDOMAIN>", // Optional
"DATADOG_STORAGE_TIER": "indexes" // Optional: indexes | online-archives | flex
}
}
}
Expand Down
37 changes: 35 additions & 2 deletions src/tools/logs/tool.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
import { ExtendedTool, ToolHandlers } from '../../utils/types'
import { v2 } from '@datadog/datadog-api-client'
import { log } from '../../utils/helper'
import { createToolSchema } from '../../utils/tool'
import { GetLogsZodSchema, GetAllServicesZodSchema } from './schema'
import { ExtendedTool, ToolHandlers } from '../../utils/types'
import { GetAllServicesZodSchema, GetLogsZodSchema } from './schema'

type LogsToolName = 'get_logs' | 'get_all_services'
type LogsTool = ExtendedTool<LogsToolName>

// Storage tier configuration from environment
const SUPPORTED_STORAGE_TIERS = ['indexes', 'online-archives', 'flex'] as const
type StorageTier = (typeof SUPPORTED_STORAGE_TIERS)[number]

const configuredStorageTier: StorageTier | undefined = (() => {
const value = process.env.DATADOG_STORAGE_TIER
if (!value) {
return undefined
}

const normalized = value.toLowerCase()
if (!SUPPORTED_STORAGE_TIERS.includes(normalized as StorageTier)) {
log(
'error',
`Invalid DATADOG_STORAGE_TIER="${value}". Supported values: ${SUPPORTED_STORAGE_TIERS.join(
', ',
)}`,
)
return undefined
}

return normalized as StorageTier
})()

export const LOGS_TOOLS: LogsTool[] = [
createToolSchema(
GetLogsZodSchema,
Expand Down Expand Up @@ -36,6 +61,10 @@ export const createLogsToolHandlers = (
// `from` and `to` are in epoch seconds, but the Datadog API expects milliseconds
from: `${from * 1000}`,
to: `${to * 1000}`,
// Optional storage tier for Logs v2 (indexes, online-archives, flex)
...(configuredStorageTier
? { storageTier: configuredStorageTier }
: {}),
},
page: {
limit,
Expand Down Expand Up @@ -70,6 +99,10 @@ export const createLogsToolHandlers = (
// `from` and `to` are in epoch seconds, but the Datadog API expects milliseconds
from: `${from * 1000}`,
to: `${to * 1000}`,
// Optional storage tier for Logs v2 (indexes, online-archives, flex)
...(configuredStorageTier
? { storageTier: configuredStorageTier }
: {}),
},
page: {
limit,
Expand Down