Skip to main content
Glama

datadog

by didlawowo

Datadog 模型上下文协议 (MCP) 🔍

一个基于 Python 的工具,用于与 Datadog API 交互并从您的基础架构获取监控数据。此 MCP 通过简单的界面提供对监控状态和 Kubernetes 日志的轻松访问。

Datadog 功能🌟

  • 监控状态跟踪:获取并分析特定的监控状态
  • Kubernetes 日志分析:从 Kubernetes 集群中提取并格式化错误日志

先决条件📋

  • Python 3.11+
  • Datadog API 和应用程序密钥(具有正确的权限)
  • 访问 Datadog 网站

安装🔧

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Datadog:

npx -y @smithery/cli install @didlawowo/mcp-collection --client claude

所需软件包:

datadog-api-client fastmcp loguru icecream python-dotenv uv

环境设置🔑

使用您的 Datadog 凭证创建一个.env文件:

DD_API_KEY=your_api_key DD_APP_KEY=your_app_key

为 MCP 设置 Claude 桌面设置 🖥️

  1. 安装 Claude Desktop
# Assuming you're on macOS brew install claude-desktop # Or download from official website https://claude.ai/desktop
  1. 设置 Datadog MCP 配置:
# on mac is ~/Library/Application\ Support/Claude/claude_desktop_config.json # Add this to your claude config json ```json "Datadog-MCP-Server": { "command": "uv", "args": [ "run", "--with", "datadog-api-client", "--with", "fastmcp", "--with", "icecream", "--with", "loguru", "--with", "python-dotenv", "fastmcp", "run", "/your-path/mcp-collection/datadog/main.py" ], "env": { "DD_API_KEY": "xxxx", "DD_APP_KEY": "xxx" } },

用法💻

获取日志

获取监视器

建筑🏗

  • FastMCP Base :利用 FastMCP 框架进行工具管理
  • 模块化设计:监视器和日志的独立功能
  • 类型安全:通过 Python 类型提示提供全面的类型支持
  • API 抽象:包装 Datadog API 调用并进行错误处理

我将添加有关 MCP 和 Claude Desktop 设置的部分:

模型上下文协议(MCP)简介🤖

什么是 MCP?

模型上下文协议 (MCP) 是一个框架,允许 AI 模型以标准化的方式与外部工具和 API 交互。它使 Claude 等模型能够:

  • 访问外部数据
  • 执行命令
  • 与 API 交互
  • 在对话中保持上下文

MCP 服务器的一些示例

https://github.com/punkpeye/awesome-mcp-servers?tab=readme-ov-file

MCP 设置教程

https://medium.com/@pedro.aquino.se/how-to-use-mcp-tools-on-claude-desktop-app-and-automate-your-daily-tasks-1c38e22bc4b0

工作原理 - 可用功能🛠️

LLM 使用提供的函数来获取数据并使用它

1. 获取监控状态

get_monitor_states( name: str, # Monitor name to search timeframe: int = 1 # Hours to look back )

例子:

response = get_monitor_states(name="traefik") # Sample Output { "id": "12345678", "name": "traefik", "status": "OK", "query": "avg(last_5m):avg:traefik.response_time{*} > 1000", "message": "Response time is too high", "type": "metric alert", "created": "2024-01-14T10:00:00Z", "modified": "2024-01-14T15:30:00Z" }

2. 获取 Kubernetes 日志

get_k8s_logs( cluster: str, # Kubernetes cluster name timeframe: int = 5, # Hours to look back namespace: str = None # Optional namespace filter )

例子:

logs = get_k8s_logs( cluster="prod-cluster", timeframe=3, namespace="default" ) # Sample Output { "timestamp": "2024-01-14T22:00:00Z", "host": "worker-1", "service": "nginx-ingress", "pod_name": "nginx-ingress-controller-abc123", "namespace": "default", "container_name": "controller", "message": "Connection refused", "status": "error" }
# Install as MCP extension cd datadog task install-mcp

4.验证安装

在克劳德的聊天桌面

检查 Claude 中的 Datadog 连接

设置克劳德

5. 使用 Datadog MCP 工具

安全注意事项

  • 将 API 密钥存储在.env
  • MCP 在隔离环境中运行
  • 每个工具都有定义的权限
  • 实施速率限制

故障排除

使用 MCP 检查器

# Launch MCP Inspector for debugging task run-mcp-inspector

MCP 检查器提供:

  • 实时查看MCP服务器状态
  • 函数调用日志
  • 错误追踪
  • API响应监控

常见问题和解决方案

  1. API 身份验证错误
    Error: (403) Forbidden
    ➡️ 检查 .env 中的 DD_API_KEY 和 DD_APP_KEY
  2. MCP 连接问题
    Error: Failed to connect to MCP server
    ➡️ 验证你的 claude_desktop_config.json 路径和内容
  3. 未找到监视器
    Error: No monitor found with name 'xxx'
    ➡️ 检查监视器名称拼写和大小写
  4. 日志可以在这里找到

替代文本

贡献🤝

请随意:

  1. 未解决的错误问题
  2. 提交 PR 以进行改进
  3. 添加新功能

注释📝

  • 对 Datadog EU 站点进行 API 调用
  • 监控状态的默认时间范围为 1 小时
  • 设置页面大小限制以处理大多数用例
-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

提供对来自 datadog 的监视器和集群日志的访问

  1. Datadog 功能🌟
    1. 先决条件📋
      1. 安装🔧
        1. 通过 Smithery 安装
      2. 环境设置🔑
        1. 为 MCP 设置 Claude 桌面设置 🖥️
          1. Sample Output
            1. Sample Output
              1. Install as MCP extension
                1. Launch MCP Inspector for debugging
                  1. 贡献🤝
                  2. 注释📝

                Related MCP Servers

                • -
                  security
                  F
                  license
                  -
                  quality
                  Integrates with Sumo Logic's API to enable log search with configurable queries and time ranges, supporting error handling and easy deployment via Docker.
                  Last updated -
                  TypeScript
                • A
                  security
                  A
                  license
                  A
                  quality
                  The MCP server provides an interface to the Datadog API, enabling seamless management of incidents, monitoring, logs, dashboards, metrics, traces, and hosts. Its extensible design allows easy integration of additional Datadog APIs for future expansions.
                  Last updated -
                  14
                  322
                  36
                  TypeScript
                  Apache 2.0
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  An MCP server that allows AI assistants to access AWS CloudWatch logs by listing log groups and reading log entries.
                  Last updated -
                  4
                  Python

                View all related MCP servers

                MCP directory API

                We provide all the information about MCP servers via our MCP API.

                curl -X GET 'https://glama.ai/api/mcp/v1/servers/didlawowo/mcp-collection'

                If you have feedback or need assistance with the MCP directory API, please join our Discord server