A lightweight, real-time database performance monitor that provides instant visibility into query execution patterns and bottlenecks.
Most database monitoring tools are either too heavy (full APM suites) or too manual (running EXPLAIN repeatedly in psql). Redline sits in the middle: a single binary that connects to your database and streams performance insights in real-time.
Built to understand how production databases actually fail under load.
┌─────────────┐
│ PostgreSQL │
│ │
│ pg_stat_* │
└──────┬──────┘
│ read-only
▼
┌─────────────┐
│ db-monitor │ ←─ polls every 1-2s
│ (Go) │ computes deltas
│ │ detects regressions
└──────┬──────┘
│ WebSocket
▼
┌─────────────┐
│ Web UI │ ←─ live updates
│ (React) │ query details
│ │ EXPLAIN plans
└─────────────┘
Key Design Principles:
- Zero schema changes (only requires
pg_stat_statementsextension) - Read-only connections
- Stream interpreted events, not raw data
- In-memory state with optional persistence
- Single binary deployment
- Real-time Query Monitoring - See execution time, call frequency, and trends as they happen
- Intelligent Alerting - Automatic detection of performance regressions and anomalies
- On-Demand Query Plans - Click any query to see its
EXPLAINplan with highlighted bottlenecks - Delta Analysis - Track changes in query performance over rolling time windows
- Query Normalization - Automatic grouping of parameterized queries
Fastest way:
docker compose upOpen http://localhost:3000 to see live monitoring.
Detailed setup: See QUICKSTART.md
Environment variables:
DB_HOST=localhost
DB_PORT=5432
DB_USER=readonly
DB_NAME=postgres
DB_SSLMODE=disable
POLL_INTERVAL=2s
WS_PORT=8081| Metric | Source | Purpose |
|---|---|---|
| Query text | pg_stat_statements |
Identity & normalization |
| Execution time | total_exec_time / calls |
Performance baseline |
| Call frequency | calls delta |
Load patterns |
| Active queries | pg_stat_activity |
Current state |
| Wait events | pg_stat_activity |
Contention diagnosis |
.
├── cmd/
│ └── db-monitor/ # Main entry point
├── internal/
│ ├── collector/ # Polling & delta computation
│ ├── db/ # Database queries
│ ├── models/ # Core types
│ ├── server/ # HTTP & WebSocket server
│ └── ws/ # WebSocket hub
├── web/ # React frontend
├── docker/ # Docker setup
└── docker-compose.yml # One-command demo
- PostgreSQL only (MySQL support planned)
- No authentication (not production-ready as-is)
- In-memory only (no historical persistence beyond rolling windows)
- Single database (no multi-tenant support)
Given more time, the natural extensions would be:
- Alert Rules - Configurable thresholds with webhooks
- Index Recommendations - Analyze query patterns to suggest missing indexes
- Query Comparison - Diff EXPLAIN plans before/after changes
- Multi-Database - Monitor multiple instances from one UI
- Historical Storage - Optional persistence layer for long-term analysis
Redline doesn't just show current stats—it computes deltas between poll intervals:
delta := current.TotalExecTime - previous.TotalExecTime
callDelta := current.Calls - previous.Calls
meanLatency := delta / float64(callDelta)This enables:
- Trend detection (is this query getting slower?)
- Anomaly detection (sudden spike in calls?)
- Rate calculations (queries/second, latency changes)
Uses PostgreSQL's built-in queryid when available, with fallback normalization:
- Strip literal values (
WHERE id = 123→WHERE id = ?) - Normalize whitespace
- Preserve query structure for meaningful grouping
When you click a query:
- Frontend requests explanation for
queryid - Go service looks up normalized query text
- Executes
EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) - Parses plan tree to extract:
- Sequential vs index scans
- Rows filtered vs returned
- Buffer hits/misses
- Actual execution time per node
MIT
Note: This is a monitoring tool, not a replacement for proper database administration. Always test in non-production environments first.