{ "dashboard": { "id": null, "title": "Database Performance", "tags": ["database", "performance"], "timezone": "Asia/Kuala_Lumpur", "panels": [ { "id": 1, "title": "Database Connections", "type": "graph", "gridPos": {"h": 8, "w": 12, "x": 0, "y": 0}, "targets": [ { "expr": "pg_stat_database_numbackends", "legendFormat": "Active Connections" }, { "expr": "pg_settings_max_connections", "legendFormat": "Max Connections" } ], "yaxes": [{"label": "Connections"}] }, { "id": 2, "title": "Database Query Performance", "type": "graph", "gridPos": {"h": 8, "w": 12, "x": 12, "y": 0}, "targets": [ { "expr": "rate(pg_stat_statements_total_time_ms[5m])", "legendFormat": "Total Query Time" }, { "expr": "rate(pg_stat_statements_calls[5m])", "legendFormat": "Query Calls" } ], "yaxes": [{"label": "Rate"}] }, { "id": 3, "title": "Database Transactions", "type": "graph", "gridPos": {"h": 8, "w": 12, "x": 0, "y": 8}, "targets": [ { "expr": "rate(pg_stat_database_xact_commit[5m])", "legendFormat": "Commits" }, { "expr": "rate(pg_stat_database_xact_rollback[5m])", "legendFormat": "Rollbacks" } ], "yaxes": [{"label": "Transactions/sec"}] }, { "id": 4, "title": "Database Locks", "type": "graph", "gridPos": {"h": 8, "w": 12, "x": 12, "y": 8}, "targets": [ { "expr": "pg_locks_count", "legendFormat": "Active Locks" }, { "expr": "rate(pg_stat_database_deadlocks[5m])", "legendFormat": "Deadlocks/sec" } ], "yaxes": [{"label": "Count"}] }, { "id": 5, "title": "Database Cache Hit Rate", "type": "graph", "gridPos": {"h": 8, "w": 12, "x": 0, "y": 16}, "targets": [ { "expr": "rate(pg_stat_database_blks_hit[5m]) / (rate(pg_stat_database_blks_hit[5m]) + rate(pg_stat_database_blks_read[5m])) * 100", "legendFormat": "Cache Hit Rate %" } ], "yaxes": [{"label": "Hit Rate %"}] }, { "id": 6, "title": "Database Size", "type": "graph", "gridPos": {"h": 8, "w": 12, "x": 12, "y": 16}, "targets": [ { "expr": "pg_database_size_bytes", "legendFormat": "Database Size" } ], "yaxes": [{"label": "Bytes"}] }, { "id": 7, "title": "Table Access Statistics", "type": "table", "gridPos": {"h": 8, "w": 24, "x": 0, "y": 24}, "targets": [ { "expr": "pg_stat_user_tables", "format": "table", "legendFormat": "{{relname}}" } ], "fieldConfig": { "defaults": { "custom": { "align": "auto", "displayMode": "auto" } } } }, { "id": 8, "title": "Database Replication Lag", "type": "graph", "gridPos": {"h": 8, "w": 12, "x": 0, "y": 32}, "targets": [ { "expr": "pg_stat_replication replication_lag", "legendFormat": "Replication Lag" } ], "yaxes": [{"label": "Seconds"}] }, { "id": 9, "title": "Database Uptime", "type": "stat", "gridPos": {"h": 4, "w": 6, "x": 12, "y": 32}, "targets": [ { "expr": "pg_postmaster_start_time_seconds", "legendFormat": "Uptime" } ] } ], "time": { "from": "now-1h", "to": "now" }, "refresh": "30s" } }