TL;DR
Database Monitoring Dashboard is a monitoring workflow that chains Postgres + Grafana to automate a common task. Stream Postgres metrics — query latency, lock waits, vacuum stats — into Grafana for a live operations dashboard. Once configured, it runs through Claude Code, Cursor, Windsurf or any MCP-compatible AI agent.
Database Monitoring Dashboard
Stream Postgres metrics — query latency, lock waits, vacuum stats — into Grafana for a live operations dashboard.
How it works
Local CLI only
None of these MCPs are hosted yet. Install and run the recipe locally:
mcpizy recipe install postgres-grafana-monitoringWhy this combo?
Postgres exposes rich internal telemetry through system views; Grafana visualizes it as time-series dashboards with alerting. Together they replace the reactive 'why is the database slow?' investigation with proactive visibility into exactly which queries, connections, and vacuum cycles are causing problems.
Without this workflow
Database slows down. No idea why. Run EXPLAIN manually on random queries. Find the slow one 45 minutes later after users are already complaining.
With MCPizy
Grafana shows query latency percentiles in real time. Alert fires when p99 crosses 200ms. Issue identified and fixed before users notice.
Business value
Concrete ROI — not marketing fluff.
Time saved
- Connection pool alerts prevent the #1 cause of 'site down' on scaling startups (connection exhaustion)
Workflow steps
- 1Enable pg_stat_statements extension
- 2Scrape slow queries every 60 seconds
- 3Export metrics to Grafana via Postgres data source
- 4Set alert threshold for p99 query time
- 5Page on-call when SLO is breached
Use cases
- Real-time dashboard showing slowest queries and their frequency
- Lock wait monitoring to catch deadlock patterns before they cause outages
- Vacuum and autovacuum tracking to prevent table bloat
- Connection pool utilization alerts before the database runs out of connections
Agent prompt (copy into Claude Code)
This prompt is the workflow. Paste into Claude Code, Cursor, or Windsurf.
You are a Postgres-monitoring agent. Runs every minute via cron.
Each cycle:
1. Call postgres.execute_sql: SELECT * FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 20
2. Call postgres.execute_sql: SELECT waiting.locktype, waiting.relation::regclass, waiting.mode, blocking.pid FROM pg_locks ... to get lock waits
3. Call postgres.execute_sql: SELECT datname, numbackends, xact_commit, xact_rollback FROM pg_stat_database
4. Push metrics to Grafana via grafana.push_metrics({query_p99_ms, slow_queries_count, lock_wait_count, active_connections, rollbacks_per_sec})
5. If p99 > ${P99_THRESHOLD_MS}, call grafana.create_alert or post to slack (if wired) with top 5 slow query signatures
Keep sampling lightweight — use pg_stat_statements.reset() only weekly, not per sample.Trigger & credentials
How this workflow fires and what env vars you need.
* * * * * # every minute
POSTGRES_URLRead-only Postgres connection URL with pg_stat_statements access
e.g. postgresql://monitor:password@db-host:5432/app
GRAFANA_URLGrafana server URL
e.g. https://grafana.company.com
P99_THRESHOLD_MSp99 latency threshold that triggers an alert
e.g. 200
One-command deploy
Install everything — MCPs, prompt, env template — in a single call.
$ mcpizy recipe install postgres-grafana-monitoring ✓ Installs all 2 MCP servers ✓ Writes prompt to ~/.mcpizy/prompts/postgres-grafana-monitoring.md ✓ Generates .env.example in current directory ✓ Ready to paste into Claude Code
Requires mcpizy CLI v1.1+ — install via npm i -g mcpizy.
Quick install (MCPs only)
$ mcpizy install postgres && mcpizy install grafanaMore Monitoring recipes
Database Change Alerts
Get a Slack alert whenever a critical Supabase table row is created, updated, or deleted — ideal for audit trails.
Error Alerting Pipeline
Sentry new issues are de-duplicated, enriched with commit info, and routed to the right Slack channel based on project.
Alert Routing from Grafana
Grafana alerts are enriched with runbook links and routed to the correct Slack channel based on severity and team labels.
Analytics Dashboard
Connect ClickHouse to Grafana to build real-time analytics dashboards over billions of events with sub-second query times.
Frequently asked questions
What is this workflow?
Database Monitoring Dashboard is a monitoring automation that uses Postgres + Grafana together via the Model Context Protocol. Stream Postgres metrics — query latency, lock waits, vacuum stats — into Grafana for a live operations dashboard.
How long does setup take?
Setup takes around 20 min setup, continuous database visibility. You install the required MCP servers with `mcpizy install postgres && mcpizy install grafana`, connect your accounts, and the workflow is ready to run.
What does this workflow change in practice?
Connection pool alerts prevent the #1 cause of 'site down' on scaling startups (connection exhaustion).
Which MCP servers do I need for this?
You need 2 MCP servers: Postgres (mcpizy install postgres), Grafana (mcpizy install grafana). All are installable in one command via the MCPizy CLI and configured in your `.claude.json` or `.cursor/mcp.json`.
Does this work with Claude Code, Cursor, and Windsurf?
Yes. The workflow runs with any MCP-compatible AI agent — Claude Code, Claude Desktop, Cursor, Windsurf, VS Code with Copilot, and custom agents built on the MCP SDK. The MCP servers are identical across clients; only the config file path (`.claude.json` vs `.cursor/mcp.json`) changes.
Start building this workflow
Install the required MCPs from the directory and automate this in 20 min setup.
$ mcpizy install postgres && mcpizy install grafana
Free to install. Connect your accounts and this workflow runs itself.