aj-geddes avatar

Database Monitoring

Covers the essentials for keeping tabs on database health, from connection counts and query duration to index usage and lock contention. The queries here are PostgreSQL-focused but the monitoring principles apply broadly. You'll want this when you're setting up observables for the first time, diagnosing slow queries, or building dashboards to catch problems before they wake you up. The reference guides break down connection monitoring, query performance, and table/index metrics into copy-paste examples. It's practical stuff, though you'll still need to wire these queries into whatever monitoring stack you're actually running.

skills.sh installs
467
GitHub stars
379
last updated
Aug 21, 2026

Install

$ npx -y skills add aj-geddes/useful-ai-prompts --skill database-monitoring --agent claude-code

Installs into .claude/skills of the current project.

Files

Database Monitoring

Table of Contents

Overview

Implement comprehensive database monitoring for performance analysis, health checks, and proactive alerting. Covers metrics collection, analysis, and troubleshooting strategies.

When to Use

  • Performance baseline establishment
  • Real-time health monitoring
  • Capacity planning
  • Query performance analysis
  • Resource utilization tracking
  • Alerting rule configuration
  • Incident response and troubleshooting

Quick Start

Minimal working example:

-- View current connections
SELECT
  pid,
  usename,
  application_name,
  client_addr,
  state,
  query_start,
  state_change
FROM pg_stat_activity
WHERE state != 'idle'
ORDER BY query_start DESC;

-- Count connections per database
SELECT
  datname,
  COUNT(*) as connection_count,
  MAX(EXTRACT(EPOCH FROM (NOW() - query_start))) as max_query_duration_sec
FROM pg_stat_activity
GROUP BY datname;

-- Find idle transactions
SELECT
  pid,
  usename,
// ... (see reference guides for full implementation)

Sponsors

Details

Repository
github.com/aj-geddes/useful-ai-prompts
Categories
Backend & APIs, DevOps & CI/CD, AI & Agent Building, Debugging, Databases
First seen
Jun 3, 2026

More from aj-geddes/useful-ai-prompts

All 258
1auth0 avatarauth0-fastapi-apiauth0/agent-skillsUse when protecting FastAPI endpoints with JWT Bearer token validation, scope checks, or DPoP binding. Integrates auth0-fastapi-api for stateless APIs receiving461skills.sh installs
2aj-geddes avatarapi-filtering-sortingaj-geddes/useful-ai-promptsImplement advanced filtering and sorting capabilities for APIs with query parsing, field validation, and optimization. Use when building search features, comple450skills.sh installs
3aj-geddes avatardatabase-shardingaj-geddes/useful-ai-promptsImplement database sharding for horizontal scalability. Use when scaling large databases, distributing data across multiple servers, or designing sharded archit446skills.sh installs
4bobmatnyc avatarhono-middlewarebobmatnyc/claude-mpm-skillsHono middleware patterns - creation, composition, built-in middleware, and execution order for web applications444skills.sh installs
5sickn33 avatardatabase-optimizersickn33/antigravity-awesome-skillsdatabase optimizer436skills.sh installs
6trading212-labs avatartrading212-apitrading212-labs/agent-skillstrading212 api433skills.sh installs