Datadog监控分析服务器

为AI助手提供全面Datadog可观测性访问的MCP服务器,支持日志搜索、APM追踪过滤、智能采样和跨数据源关联分析。

  • by TANTIOPE
  • TypeScript
  • 本地部署
  • 6 星标
  • 更新于
在 GitHub 查看 TANTIOPE/datadog-mcp-server

使用说明

Datadog MCP服务器

免责声明:这是一个社区维护的项目,与Datadog,股份有限公司没有正式关联、认可或支持。此MCP服务器使用Datadog API,但是独立开发的。

MCP服务器为AI助手提供完整的Datadog可观察性访问。具有类似grep的日志搜索、具有持续时间/状态/错误查询的APM跟踪过滤、用于令牌效率的智能采样模式以及日志、跟踪和指标之间的互相关功能。支持两者 stdio (当地)和 http (远程/Kubernetes)传输。

快速开始

最小的Claude桌面/VS代码/光标配置——只有两个必需的键:

{
  "mcpServers": {
    "datadog": {
      "command": "npx",
      "args": ["-y", "datadog-mcp"],
      "env": {
        "DD_API_KEY": "your-api-key",
        "DD_APP_KEY": "your-app-key"
      }
    }
  }
}

通过可选调整(欧盟站点、自定义默认限制、更长的日志窗口):

{
  "mcpServers": {
    "datadog": {
      "command": "npx",
      "args": ["-y", "datadog-mcp"],
      "env": {
        "DD_API_KEY": "your-api-key",
        "DD_APP_KEY": "your-app-key",
        "DD_SITE": "datadoghq.eu",
        "MCP_DEFAULT_LIMIT": "50",
        "MCP_DEFAULT_LOG_LINES": "200",
        "MCP_DEFAULT_METRIC_POINTS": "1000",
        "MCP_DEFAULT_TIME_RANGE": "24"
      }
    }
  }
}

要作为HTTP服务器运行(例如在容器或Kubernetes pod中),请向相同的容器或pod中添加传输变量 env 块:

"env": {
  "DD_API_KEY": "your-api-key",
  "DD_APP_KEY": "your-app-key",
  "MCP_TRANSPORT": "http",
  "MCP_PORT": "3000",
  "MCP_HOST": "0.0.0.0"
}

配置

所需的环境变量

DD_API_KEY=your-api-key
DD_APP_KEY=your-app-key

可选环境变量

DD_SITE=datadoghq.com  # Default. Use datadoghq.eu for EU, etc.

# Limit defaults (fallbacks when the AI doesn't specify)
MCP_DEFAULT_LIMIT=50              # General tools default limit
MCP_DEFAULT_LOG_LINES=200         # Logs tool default limit
MCP_DEFAULT_METRIC_POINTS=1000    # Metrics timeseries data points
MCP_DEFAULT_TIME_RANGE=24         # Default time range in hours

# Transport (alternative to CLI flags — useful in Kubernetes)
MCP_TRANSPORT=stdio               # stdio | http
MCP_PORT=3000                     # HTTP port
MCP_HOST=0.0.0.0                  # HTTP host

可选标志

--site=datadoghq.com     # Datadog site (overrides DD_SITE)
--transport=stdio|http   # Transport mode (default: stdio)
--port=3000              # HTTP port when using http transport
--host=0.0.0.0           # HTTP host when using http transport
--read-only              # Block all write operations
--disable-tools=synthetics,rum,security    # Comma-separated list of tools to disable

运输

传输 何时使用 端点
stdio (默认) 本地MCP客户端--克劳德桌面、光标、VS代码 n/a(进程stdin/stdout)
http 远程/容器/Kubernetes POST /mcp · GET /mcp 上海证券交易所 DELETE /mcp · GET /health

选择 --transport=http 或 MCP_TRANSPORT=http.

部署

码头工人

{
  "mcpServers": {
    "datadog": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "DD_API_KEY",
        "-e", "DD_APP_KEY",
        "-e", "DD_SITE",
        "ghcr.io/tantiope/datadog-mcp"
      ],
      "env": {
        "DD_API_KEY": "your-api-key",
        "DD_APP_KEY": "your-app-key",
        "DD_SITE": "datadoghq.com"
      }
    }
  }
}

Kubernetes

使用环境变量(而不是容器参数)进行传输配置:

env:
  - name: DD_API_KEY
    value: "your-api-key"
  - name: DD_APP_KEY
    value: "your-app-key"
  - name: MCP_TRANSPORT
    value: "http"
  - name: MCP_PORT
    value: "3000"
  - name: MCP_HOST
    value: "0.0.0.0"

注: Kubernetes args: 替换整个Dockerfile CMD,导致Node.js接收标志而不是您的应用程序。环境变量避免了这个问题。

工具

工具 操作 类别 描述 必填范围
monitors list Alerting 列出具有可选筛选器的监视器 monitors_read
monitors get Alerting 按ID获取监视器 monitors_read
monitors 搜索 警报 按查询搜索监视器 monitors_read
monitors create Alerting 新建一个监视器; config 根据包含记录选项(notifyNoData、renotifyInterval、threshold等)的类型化模式进行验证——未知密钥出现在 warnings.通行证 dry_run: true 验证而不创建(使用 /api/v1/monitor/validate,在只读模式下允许)。 monitors_write
monitors update Alerting 更新现有监视器;与相同的验证模式 create接受部分配置;验证错误在任何HTTP调用之前短路为 EINVALID_MONITOR_CONFIG: monitors_write
monitors 预览 警报 渲染监视器模板(内联 message 或通过 monitor_id/id)可选 context 变量和条件。退货 {rendered, variablesUsed, variablesMissing, conditionalsResolved, tagConditionalsResolved}.支持Datadog Mustache子集:变量替换+六个有记录的条件语句(is_alert, is_warning, is_no_data, is_recovery, is_alert_to_warning, is_warning_to_alert)+标签条件 {{#is_match "tag" "val"}}/{{#is_exact_match "tag" "val"}} (以及 ^ 否定); {{#each}}/游击队投球 EUNSUPPORTED_TEMPLATE_SYNTAX。只读。 monitors_read
monitors test_nnotification 警报 已知限制:返回 ENOT_SUPPORTED --Datadog没有用于触发测试通知的公共REST端点。响应中的文档指针。 无
monitors delete Alerting 删除监视器 monitors_write
monitors 静音 警报 将显示器静音 monitors_write
monitors 取消静音 警报 取消显示器静音 monitors_write
monitors top Alerting 按警报频率排列的前N个监视器,具有真实监视器名称和上下文细分。 警告: total_count 包括翻新/重新评估(Datadog每次都会发出翻新事件 renotify_interval 警报时的分钟数)。对于真正的火灾使用 action=history. monitors_read
monitors history Alerting 统计并列出一个监视器在一个时间窗口内的实际状态转换。筛选条件 transitionType (默认值 ["alert","alert recovery"] --火灾+恢复,不包括翻修)和可选 group.退货 {transitions: [...], count, meta} 哪里 count 是实际转换的数量(例如,对于一个7天内始终保持警报的燃烧率监测器:98个原始事件vs 38个真正的转变). monitors_read, events_read
dashboards list 可视化 列出所有仪表板 dashboards_read
dashboards get 可视化 按ID获取仪表板 dashboards_read
dashboards 创建 可视化 创建新仪表板 dashboards_write
dashboards 更新 可视化 更新仪表板 dashboards_write
dashboards delete 可视化 删除仪表板 dashboards_write
logs search Logs 使用查询语法和筛选器搜索日志 logs_read_data, logs_read_index_data
logs aggregate Logs 使用groupBy聚合日志数据 logs_read_data
logs_pipelines list,get Logs Config 检查日志处理管道及其处理器 logs_read_config
logs_pipelines 创建、更新、删除、重新排序 日志配置 作者管道和处理器链 logs_write_config
logs_pipelines get_order 日志配置 读取管道评估顺序 logs_read_config
logs_indexes 列表,获取 日志配置 检查索引(过滤器、保留、Flex层、排除过滤器); create/delete 用户界面仅针对Datadog,不公开 logs_read_config
logs_indexes 更新、重新排序 日志配置 更新索引过滤器/保留/配额和重新排序评估 logs_write_config
logs_indexes get_order 日志配置 读取索引求值顺序 logs_read_config
logs_archives 列表,获取 日志配置 检查日志档案(S3/GCS/AAzure目标);每个提供商的凭据字段将原封不动地转发 logs_read_archives
logs_archives 创建、更新、删除、重新排序 日志配置 管理归档目标; destination.type 已验证 `s3 gcs
logs_archives get_order 日志配置 读取存档评估顺序 logs_read_archives
metrics query Metrics 查询时间序列数据。回应 meta 包括 rollupRequested (解析自 rollup(method, seconds),与 methodInferred 旗), rollupEffective (从返回的点列表间隔得出的间隔+重复数据消除 intervalsObserved 对于多系列),以及 rollupOverridden: boolean 因此呼叫者可以检测到Datadog何时无声地降采样。 metrics_read, timeseries_query
metrics 搜索 指标 按名称搜索指标 metrics_read
metrics list 度量 列出活动度量 metrics_read
metrics 元数据 度量 获取度量元数据 metrics_read
traces 搜索 APM 带筛选器的搜索范围 apm_read
traces 聚合 APM 聚合跟踪数据 apm_read
traces 服务 APM 列出APM服务 apm_service_catalog_read
events list 事件 列出事件 events_read
events get 事件 按ID获取事件 events_read
events create Events 创建事件 events_read
events search Events 使用v2 API和游标分页搜索事件。可选的 transitionType 过滤器(例如。 ["alert","alert recovery"])限制监视状态转换事件——没有它, source:alert 包括翻新。用于监控特定火灾 monitors action=history.可选 timezone 添加 *Local ISO 8601与每个时间戳都是兄弟关系。零结果响应包括 diagnostics 数组提示原因(UNINDEXED_TAG_PREFIX, NARROW_TIME_RANGE, RESTRICTIVE_SOURCE_FILTER). events_read
events 柱状图 事件 服务器端按事件分组 hour_of_day, day_of_week,或 day_of_month 在IANA timezone (DST安全通过 Intl.DateTimeFormat).接受相同 transitionType 过滤器为 search 因此,监测直方图可以排除相关性。游标对基础搜索进行分页;帽子在 limits.maxEventsForHistogram (默认值为5000, MCP_MAX_EVENTS_HISTOGRAM env变量)。当盖子被击中时,会返回 bucketCountIncomplete: true 和 nextCursor 为了继续。 events_read
events aggregate Events 按monitor_name、源等进行客户端聚合。 events_read
events top 事件 按计数的前N个事件组,具有通用groupBy支持(部署、配置、警报等)。没有上下文标签的组被包含为“no_context” events_read
events 时间序列 事件 带时间标记的警报趋势(每小时/每天计数) events_read
events 偶发事件 事件 使用触发器/恢复配对将重复警报消除为偶发事件 events_read
incidents 列表 事件 列出事件 incident_read
incidents get 事件 按ID获取事件 incident_read
incidents 搜索 事件 搜索事件 incident_read
incidents 创建 事件 创建事件 incident_write
incidents 更新 事件 更新事件 incident_write
incidents delete 偶发事件 删除偶发事件 incident_write
slos list SLO 列出SLO。每个项目都暴露 query, monitorIds, monitorTags, groups,以及UI url 所以往返(get→ edit → 更新)保留定义字段。 slos_read
slos get SLOs 按ID获取SLO(投影与 list). slos_read
slos 创建 SLO 创建SLO slos_write
slos 更新 SLOs 更新SLO slos_write
slos delete SLO 删除SLO slos_write
slos 历史记录 SLO 获取SLO历史记录 slos_read
synthetics list 合成药物 列出合成测试 synthetics_read
synthetics get 合成药物 按公共ID获取测试 synthetics_read
synthetics 创建 合成 创建测试 synthetics_write
synthetics 更新 合成 更新测试 synthetics_write
synthetics delete 合成 删除测试 synthetics_write
synthetics 触发器 合成 触发试运行 synthetics_write
synthetics results 合成药物 获取测试结果 synthetics_read
downtimes list 停机时间 列出停机时间 monitors_downtime
downtimes get 停机时间 按ID获取停机时间 monitors_downtime
downtimes 创建 停机时间 创建停机时间 monitors_downtime
downtimes update 停机时间 更新停机时间 monitors_downtime
downtimes cancel 停机时间 取消停机时间 monitors_downtime
downtimes listByMonitor 停机时间 列出监视器的停机时间 monitors_downtime
hosts list 基础结构 列出主机 hosts_read
hosts 总计 基础架构 获取主机总计 hosts_read
hosts 静音 基础结构 静音主机 hosts_read
hosts 取消静音 基础结构 取消主机静音 hosts_read
rum 应用程序 RUM 列出RUM应用程序 rum_read
rum 事件 RUM 搜索RUM事件 rum_read
rum 聚合 RUM 聚合RUM数据 rum_read
rum 性能 RUM 获取核心Web重要信息(LCP、FCP、CLS、FID、INP) rum_read
rum 瀑布图 RUM 获取包含资源/操作/错误的会话时间线 rum_read
security rules Security 列出安全规则 security_monitoring_rules_read
security 信号 安全 搜索安全信号 security_monitoring_signals_read
security 发现 安全 列出安全发现 security_monitoring_findings_read
notebooks list 笔记本 列出笔记本 notebooks_read
notebooks 获取 笔记本 按ID获取笔记本 notebooks_read
notebooks 创建 笔记本 创建笔记本 notebooks_write
notebooks 更新 笔记本 更新笔记本 notebooks_write
notebooks delete 笔记本 删除笔记本 notebooks_write
users list 管理员 列出用户 user_access_read
users get Admin 按ID获取用户 user_access_read
teams list 管理员 列出团队 teams_read
teams get 管理员 按ID获取团队 teams_read
teams 成员 管理员 列出团队成员 teams_read
tags list Infrastructure 列出所有标签 hosts_read
tags get Infrastructure 获取主机的标签 hosts_read
tags add Infrastructure 向主机添加标签 hosts_read
tags 更新 基础结构 更新主机标签 hosts_read
tags delete 基础结构 删除主机标记 hosts_read
usage summary 账单 使用情况摘要 usage_read
usage 主机 计费 主机使用情况 usage_read
usage 日志 账单 日志使用情况 usage_read
usage custom_metrics 计费 自定义指标使用情况 usage_read
usage indexed_spans 计费 索引跨度使用情况 usage_read
usage ingested_span 计费 ingested span使用情况 usage_read
auth 验证 验证 测试API和应用程序密钥有效性 -

极限控制

AI助手可以完全控制查询限制。这 MCP_DEFAULT_* 环境变量仅设置AI未指定限制时使用的回退——它们不会限制AI可以请求的内容。

工具 默认值 参数 说明
日志 200 limit 要返回的日志行
指标(时间序列) 1000 pointLimit 每个系列的数据点(控制分辨率)
通用工具 50 limit 返回结果

工具级令牌减少功能(compact: true 在日志上, sample: "diverse" | "spread" | "first"、现场投影、诊断)显示在每个工具的MCP描述中,并由AI在调用时选择。

显著行为

一些值得了解的模式——人工智能可以从工具描述中发现其余的模式。

  • 装修vs真正的火灾。 monitors top 和 events search 随着 source:alert 统计每只翻新Datadog发出的数量(每只 renotify_interval 而监视器处于警报状态)。要获得实际的状态转换,请使用 monitors history (默认为 transitionType: ["alert","alert recovery"])或通过 transitionType 到 events search.
  • 夏令时安全时段。 events histogram 水桶 hour_of_day / day_of_week / day_of_month 在任何IANA timezone 通过 Intl.DateTimeFormat。游标对基础搜索进行分页;上限由控制 MCP_MAX_EVENTS_HISTOGRAM (默认值为5000) bucketCountIncomplete + nextCursor 溢出。
  • 创建前验证。 monitors create 随着 dry_run: true 电话 /api/v1/monitor/validate 而不是坚持。允许进入 --read-only 模式。
  • 监控模板预览。 monitors preview 发出通知 context payload——变量替换+Datadog的六个有记录的条件(is_alert, is_warning, is_no_data, is_recovery, is_alert_to_warning, is_warning_to_alert)+标签条件 {{#is_match "tag" "val"}} (子字符串)和 {{#is_exact_match "tag" "val"}} (确切),与 ^ 否定和OR多重比较值(根据 context.variables;区分大小写)。 {{#each}} 游击队投球 EUNSUPPORTED_TEMPLATE_SYNTAX.
  • SLO往返。 slos get 项目 query, monitorIds, monitorTags, groups,以及UI url 因此,您可以编辑并反馈到 slos update 而不会删除定义字段。
  • 相互关联。 logs(sample:"diverse") → pull dd.trace_id → traces(query:"trace_id:<id>") → metrics(query:"p95:trace.express.request{service:...}") (根度量没有 .duration 百分位数)。

深层链接

每个查询响应都包含一个 datadog_url 为您的配置构建的字段 DD_SITE — datadoghq.com (默认), .eu, us3 / us5 / ap1.datadoghq.com,或 ddog-gov.com.支持 logs, metrics, traces, events, monitors, rum, slos.

贡献

欢迎投稿!如果您有任何建议、错误报告或改进建议,请随时打开问题或拉取请求。

许可证

该项目根据 Apache许可证,版本2.0.