MCP Prometheus

MCP Prometheus

An MCP server for Prometheus-based monitoring that enables users to query system metrics, resource usage, and PostgreSQL health across multiple environments. It supports both predefined diagnostic checks and custom PromQL execution for comprehensive server monitoring and troubleshooting.

Category
Visit Server

README

MCP Prometheus ๐Ÿ“ˆ

Prometheus ๊ธฐ๋ฐ˜ ๋ชจ๋‹ˆํ„ฐ๋ง์šฉ MCP ์„œ๋ฒ„์ž…๋‹ˆ๋‹ค. ์—”ํŠธ๋ฆฌํฌ์ธํŠธ๋Š” main.py์ž…๋‹ˆ๋‹ค.

Quick Start ๐Ÿš€

cd d:\MCPTools
uv sync
uv run python mcp_prometheus/main.py

ํ”„๋กœ์ ํŠธ ๊ตฌ์กฐ ๐Ÿงฉ

mcp_prometheus/
  main.py
  core/
    config.py
    runtime.py
    server.py
    time_utils.py
  domain/
    checks.py
  infra/
    prom_client.py
  tools/
    catalog.py
    checks_runner.py
    promql.py
  utils/
    query_utils.py
    summarize.py

Tools ์š”์•ฝ ๐Ÿ› ๏ธ

Tool ๋ชฉ์  ๋น„๊ณ 
list_checks ๋“ฑ๋ก๋œ ์ฒดํฌ ๋ชฉ๋ก ์กฐํšŒ id, name, description ๋ฐ˜ํ™˜
list_environments ํ™˜๊ฒฝ๋ณ„ Prometheus URL ์กฐํšŒ prod/dev_test/dr
list_servers ์ตœ๊ทผ up ๊ธฐ์ค€ ์„œ๋ฒ„ ๋ชฉ๋ก ์กฐํšŒ (instance, job) ๊ธฐ์ค€ ์ค‘๋ณต ์ œ๊ฑฐ
list_process_groups ํ”„๋กœ์„ธ์Šค ๊ทธ๋ฃน ๋ชฉ๋ก ์กฐํšŒ process_monitoring ๊ธฐ์ค€
run_check ๋‹จ์ผ ์ฒดํฌ ์‹คํ–‰ ๊ธฐ๋ณธ ๊ถŒ์žฅ
run_all_checks ์ „์ฒด ์ฒดํฌ ๋ณ‘๋ ฌ ์‹คํ–‰ step=5m ๊ณ ์ •
run_promql ์‚ฌ์šฉ์ž PromQL ์ง์ ‘ ์‹คํ–‰ approved=True ํ•„์š”

run_check ์ž…๋ ฅ ๊ฐ€์ด๋“œ ๐Ÿงญ

ํ•„์ˆ˜

  • check_id

๊ธฐ๊ฐ„

  • ์ƒ๋Œ€: hours, minutes, days
  • ์ ˆ๋Œ€: start_time_utc_iso, end_time_utc_iso
  • ์ข…๋ฃŒ ์˜คํ”„์…‹: end_offset_minutes, end_offset_hours, end_offset_days

ํƒ€๊ฒŸ ํ•„ํ„ฐ

  • server_name
  • instance (์˜ˆ: host-or-ip:9100)

ํ•„ํ„ฐ ๊ทœ์น™:

  • server_name์™€ instance๋ฅผ ํ•จ๊ป˜ ์ฃผ๋ฉด AND ์ ์šฉ
  • ํ•˜๋‚˜๋งŒ ์ฃผ๋ฉด ํ•ด๋‹น ๋ผ๋ฒจ๋งŒ ์ ์šฉ

run_promql ๊ฐ€๋“œ๋ ˆ์ผ ๐Ÿ”’

  • approved=False: ์‹คํ–‰ํ•˜์ง€ ์•Š๊ณ  ํ™•์ธ ๋ฉ”์‹œ์ง€ ๋ฐ˜ํ™˜
  • approved=True: ์‹คํ–‰

๋ชจ๋“œ:

  • instant=True -> /api/v1/query
  • instant=False -> /api/v1/query_range

์‚ฌ์šฉ ์˜ˆ์‹œ ๐Ÿ“Œ

1) ํŠน์ • ์„œ๋ฒ„ CPU ํ‰๊ท  (์ตœ๊ทผ 24์‹œ๊ฐ„)

{
  "check_id": "cpu_avg_pct",
  "hours": 24,
  "instance": "10.23.12.11:9100",
  "environment": "prod"
}

2) ํŠน์ • ์„œ๋ฒ„ ๋””์Šคํฌ ์‚ฌ์šฉ๋ฅ  (mountpoint๋ณ„)

{
  "check_id": "disk_used_pct_by_mount",
  "hours": 24,
  "server_name": "CMS AP #1",
  "environment": "prod"
}

3) ์‚ฌ์šฉ์ž PromQL ์‹คํ–‰ (instant)

{
  "promql": "up",
  "approved": true,
  "instant": true,
  "environment": "prod"
}

CHECKS Catalog โœ…

Source: domain/checks.py (CHECKS)

System / Resource

  • cpu_avg_pct: CPU average usage (%) by instance/server_name
  • cpu_peak_pct: window peak CPU usage (%) over selected range
  • mem_used_pct: memory used ratio (%)
  • mem_swap_used_pct: swap used ratio (%)
  • load15_avg: 15-minute load average
  • cpu_iowait_pct: CPU iowait ratio (%)

Disk / Filesystem

  • disk_used_pct_by_mount: filesystem used (%) by mountpoint/device (0-100 scale)
  • disk_used_top5_pct: top 5 filesystem usage (%)
  • disk_inodes_used_pct: inode usage (%)
  • fs_readonly: readonly filesystem indicator (1=readonly)
  • disk_io_busy_pct: disk I/O busy ratio (%)

Availability

  • up: target liveness (1=up, 0=down)

Network / TCP

  • net_in_bytes: inbound throughput (bytes/sec)
  • net_out_bytes: outbound throughput (bytes/sec)
  • net_errs_per_sec: RX+TX network errors per second
  • tcp_retrans_per_sec: TCP retransmit segments per second
  • tcp_established: established TCP connections
  • tcp_time_wait: TIME_WAIT TCP sockets
  • tcp_inuse: in-use TCP sockets
  • tcp_orphan: orphan TCP sockets

Process Monitoring

  • proc_cpu_pct: process group CPU usage (%)
  • proc_mem_bytes: process group memory usage (bytes)
  • proc_count: process group process count

PostgreSQL

  • pg_up: PostgreSQL exporter up state (1=up, 0=down)
  • pg_qps: PostgreSQL transactions/sec (commit + rollback)
  • pg_cache_hit_pct: PostgreSQL buffer cache hit ratio (%)
  • pg_active_conn: active PostgreSQL connections

ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์š”์•ฝ โš™๏ธ

PROM_ENV_URLS={"prod":"http://...:9090","dev_test":"http://...:9090","dr":"http://...:9090"}
PROM_URL=http://...:9090
PROM_BEARER_TOKEN=
PROM_TIMEOUT_SEC=15

ALERT_WARN_PCT=85
ALERT_CRIT_PCT=95
ALERT_SUSTAIN_MINUTES=5

PROM_MAX_SAMPLES_PER_SERIES=5000
PROM_MAX_PARALLEL_CHECKS=6

ํ™˜๊ฒฝ ์„ ํƒ ์šฐ์„ ์ˆœ์œ„:

  1. environment
  2. env_hint
  3. PROM_URL fallback

์šด์˜ ํŒ ๐Ÿ’ก

  • ๋ฆฌํฌํŠธ ์ถœ๋ ฅ ์‹œ % ๋‹จ์œ„๋ฅผ ๋ช…ํ™•ํžˆ ํ‘œ๊ธฐํ•˜์„ธ์š”.
  • ๋‹จ์ผ ์„œ๋ฒ„ ์ ๊ฒ€์€ instance ๋˜๋Š” server_name ํ•„ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.
  • disk_used_pct_by_mount ๊ฐ’์€ 0~100 ์Šค์ผ€์ผ์ž…๋‹ˆ๋‹ค. (0.8 = 0.8%)

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured