prometheus-mcp-server
Provides tools for querying Prometheus metrics, including searching metrics by pattern, retrieving metric labels and values, executing PromQL instant and range queries, and generating charts from range queries.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@prometheus-mcp-serversearch metrics matching http_*"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Prometheus MCP 服务器
这是一个简化版的Prometheus MCP服务器,用于查询指标提供 ai 分析。
快速开始
启动
设置Prometheus地址环境变量:
export PROMETHEUS_URL=your_Prometheus_endpoint启动服务器:
go run cmd/server/main.go sse服务器将在:8081端口启动,可以通过以下URL访问:
http://localhost:8081/sse
(可选) 设置日志文件路径:
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模块定义This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/qingshanyuluo/prometheus-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server