- Prometheus MCP 服务器
Content
Prometheus MCP 服务器
这是一个简化版的Prometheus MCP服务器,用于查询指标提供 ai 分析。
快速开始
启动
- 设置Prometheus地址环境变量:
export PROMETHEUS_URL=your_Prometheus_endpoint
- 启动服务器:
go run cmd/server/main.go sse
服务器将在:8081端口启动,可以通过以下URL访问:
- (可选) 设置日志文件路径:
export APP_LOG_FILE=/path/to/logfile.log
测试
npx @modelcontextprotocol/inspector node build/index.js
功能特性
AI友好化分析指标
- JSON格式输出:所有查询结果均以JSON格式返回,便于AI系统解析处理
MCP工具
-
search_metrics - 按正则表达式搜索指标
- 参数:
pattern(指标名称模式,支持正则表达式) - 示例:
http_.*匹配所有以http_开头的指标 - 返回: 匹配的指标名称列表(JSON格式)
- 参数:
-
get_metric_labels - 获取指标的所有标签
- 参数:
name(指标名称) - 示例:
http_requests_total - 返回: 该指标的所有标签列表(JSON格式,不包括
__name__标签)
- 参数:
-
get_metric_label_values - 获取指标标签的所有值
- 参数:
name(指标名称)label(标签名称)
- 示例: 获取
http_requests_total指标的method标签的所有值 - 返回: 指定标签的所有值列表(JSON格式)
- 参数:
-
query - 执行PromQL即时查询
- 参数:
query(PromQL查询语句)time(查询时间戳,格式为RFC3339或Unix时间戳,可选)
- 示例: 查询当前CPU使用率
- 返回: 查询结果(JSON格式)
- 参数:
-
query_range - 执行PromQL范围查询
- 参数:
query(PromQL查询语句)start(开始时间,格式为RFC3339或Unix时间戳(毫秒))end(结束时间,格式为RFC3339或Unix时间戳(毫秒))step(查询步长,例如'15s'、'1m')
- 示例: 查询过去1小时CPU使用率变化,每15秒一个数据点
- 返回: 范围查询结果(JSON格式)
- 参数:
-
query_chart - 执行PromQL范围查询并生成图表
- 参数:
query(PromQL查询语句)start(开始时间,格式为RFC3339或Unix时间戳(毫秒))end(结束时间,格式为RFC3339或Unix时间戳(毫秒))step(查询步长,例如'15s'、'1m')title(图表标题,可选)
- 示例: 查询过去1小时CPU使用率变化并生成图表
- 返回: 图表图片(base64编码的PNG格式)
- 参数:
服务器端
- 设置Prometheus地址:
export PROMETHEUS_URL=your_Prometheus_endpoint
- 启动服务器:
go run cmd/server/main.go sse
服务器默认将在:8081端口暴露Prometheus指标。
mcp 客户端配置
配置示例:
{
"mcpServers": {
"products-sse": {
"url": "http://localhost:8081/sse"
}
}
}
项目结构
.
├── cmd/ # 命令行程序入口
│ └── server/ # 服务器代码
├── internal/ # 内部实现
├── pkg/ # 可复用包
│ └── prometheus # Prometheus相关实现
└── go.mod # Go模块定义
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
ChatWiseThe second fastest AI chatbot™
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
WindsurfThe new purpose-built IDE to harness magic
Serper MCP ServerA Serper MCP Server
Tavily Mcp
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
DeepChatYour AI Partner on Desktop
CursorThe AI Code Editor
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题;
Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Amap Maps高德地图官方 MCP Server