feat: add database connection pool dashboard (#1182) - #1234
Merged
Mosas2000 merged 2 commits intoAug 30, 2026
Conversation
Implement comprehensive monitoring and control dashboard for database connection pool metrics. Includes: - Time-series collection of pool state (active, idle, waiting connections) - Automatic event emission for significant pool changes - REST API for metrics querying and control actions - React dashboard UI with real-time updates and gauges - Role-based authorization with full audit trail - Operator guide with common scenarios and procedures - Integration with existing Prometheus observability stack - Unit and integration test coverage - Safe rollout strategy with feature flags Features: - PoolMetricsCollector: Collects pool metrics every 5 seconds - PoolControlHandler: Validates and executes operator control actions - PoolDataQueryService: Provides historical metrics and analysis - 8 REST API endpoints with authentication and authorization - Dashboard component with real-time gauges and historical charts - Event detection for 8+ significant pool state changes - Comprehensive audit trail for all control actions Database: - db_pool_snapshots table (30-day retention) - db_pool_events table (30-day retention) - db_pool_controls table (permanent retention) - Optimized indexes for time-series queries - TimescaleDB hypertable support with PostgreSQL fallback All operations are non-blocking with comprehensive error handling. Control actions require explicit confirmation and actor identity logging. Closes StellaBridge#1182
Contributor
|
Nice implementation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1182
Implements a Database Connection Pool Dashboard for Bridge Watch (Issue #1182) that provides real-time and historical monitoring of connection pool metrics with operator controls and comprehensive audit trails.
What Changed
Backend Implementation
Data Model (
backend/src/models/db-pool-metrics/pool.model.ts):PoolSnapshotinterface for periodic metricsPoolEventinterface for significant eventsPoolControlinterface for action audit trailDatabase Schema (
backend/src/database/migrations/20260829_db_pool_dashboard.ts):db_pool_snapshotstable for time-series metrics (30-day retention)db_pool_eventstable for event log (30-day retention)db_pool_controlstable for audit trail (permanent retention)Service Layer:
PoolMetricsCollector— Collects metrics every 5 seconds, persists to database, emits eventsPoolControlHandler— Validates and executes control actions with audit loggingPoolDataQueryService— Provides database queries for dashboard dataAPI Routes (
backend/src/api/routes/db-pool.routes.ts):GET /api/v1/db-pool/metrics— Aggregated pool metricsGET /api/v1/db-pool/events— Recent events with filteringGET /api/v1/db-pool/status— Current health statusPOST /api/v1/db-pool/control— Execute control action (admin-only)GET /api/v1/db-pool/stats— Statistical summariesGET /api/v1/db-pool/latest— Most recent snapshotGET /api/v1/db-pool/events/summary— Event countsGET /api/v1/db-pool/controls/history— Audit trailAll endpoints:
Frontend Implementation
Dashboard Component (
frontend/src/components/dashboard/DbPoolDashboard.tsx):Custom Hook (
frontend/src/hooks/usePoolData.ts):Testing
Unit Tests (
backend/tests/unit/services/db-pool-monitor.test.ts):Integration Tests (
backend/tests/integration/api/db-pool.integration.test.ts):Documentation
Technical Guide (
docs/db-pool-dashboard.md):Operator Manual (
docs/db-pool-dashboard-operator-guide.md):How Verified
Code Quality
npm run lint— PASS (no errors)anyTesting
Security
Performance
Rollout Plan
Phase 1: Feature Flagged (Internal Testing)
Phase 2: Gradual Rollout
Phase 3: Full GA
Rollback
If issues occur, simply disable:
No data loss — all metrics and events remain queryable.
Acceptance Criteria
Files Changed
New Files (17 total)
Backend:
backend/src/database/migrations/20260829_db_pool_dashboard.tsbackend/src/models/db-pool-metrics/pool.model.tsbackend/src/services/db-pool-monitor/metrics-collector.tsbackend/src/services/db-pool-monitor/control-handler.tsbackend/src/services/db-pool-monitor/query-service.tsbackend/src/api/routes/db-pool.routes.tsbackend/src/api/routes/route-groups/db-pool-routes.tsbackend/tests/unit/services/db-pool-monitor.test.tsbackend/tests/integration/api/db-pool.integration.test.tsFrontend:
frontend/src/components/dashboard/DbPoolDashboard.tsxfrontend/src/hooks/usePoolData.tsDocumentation:
docs/db-pool-dashboard.mddocs/db-pool-dashboard-operator-guide.mdIMPLEMENTATION_1182_SUMMARY.mdModified Files (1 total)
backend/src/api/routes/index.ts— Added db-pool routes registrationDependencies
No new dependencies added. Uses existing:
prom-client(already in use)pg(already in use)Database Migration
To apply the schema:
To rollback:
Related Issues
Notes
Ready for review and merge. 🚀