diff --git a/.env.sample b/.env.sample index 1816f691..61b8399a 100644 --- a/.env.sample +++ b/.env.sample @@ -45,7 +45,6 @@ DATABASE_CONNECTION_TIMEOUT=3000 DATABASE_SEARCH_PATH= DATABASE_APPLICATION_NAME="Supabase Storage API" -PG_QUEUE_APPLICATION_NAME="Supabase Storage PgBoss" ## When DATABASE_POOL_URL is SET the following params are ignored DATABASE_MAX_CONNECTIONS=20 diff --git a/monitoring/grafana/dashboards/pgbouncer.json b/monitoring/grafana/dashboards/pgbouncer.json new file mode 100644 index 00000000..b61a3567 --- /dev/null +++ b/monitoring/grafana/dashboards/pgbouncer.json @@ -0,0 +1,3806 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Comprehensive PgBouncer monitoring dashboard using prometheus-community/pgbouncer_exporter metrics", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 1, + "id": 34, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 100, + "panels": [], + "title": "🔍 Overview", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "0": { + "color": "red", + "text": "DOWN" + }, + "1": { + "color": "green", + "text": "UP" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red" + }, + { + "color": "green", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 0, + "y": 1 + }, + "id": 1, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "pgbouncer_up{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ instance }}", + "refId": "A" + } + ], + "title": "Exporter Status", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "purple" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 3, + "y": 1 + }, + "id": 2, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "pgbouncer_config_max_client_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ instance }}", + "refId": "A" + } + ], + "title": "Max Client Connections", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "purple" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 6, + "y": 1 + }, + "id": 3, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "pgbouncer_config_max_user_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ instance }}", + "refId": "A" + } + ], + "title": "Max User Connections", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 9, + "y": 1 + }, + "id": 4, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "sum(pgbouncer_pools_client_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Total Active Clients", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Total clients currently waiting for a server connection. Non-zero = pool pressure.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "yellow", + "value": 1 + }, + { + "color": "red", + "value": 5 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 12, + "y": 1 + }, + "id": 5, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "sum(pgbouncer_pools_client_waiting_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Clients Waiting ⚠️", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Ratio of active server connections to total pool size across all databases.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "yellow", + "value": 0.7 + }, + { + "color": "red", + "value": 0.9 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 4, + "x": 15, + "y": 1 + }, + "id": 6, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "sum(pgbouncer_pools_server_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}) / (sum(pgbouncer_databases_pool_size{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}) > 0)", + "legendFormat": "utilization", + "range": true, + "refId": "A" + } + ], + "title": "Server Conn Utilization", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Longest time any client has been waiting for a server connection. High = pool exhaustion.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "yellow", + "value": 1 + }, + { + "color": "red", + "value": 5 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 5, + "x": 19, + "y": 1 + }, + "id": 7, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "max(pgbouncer_pools_client_maxwait_seconds{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Max Client Wait ⚠️", + "type": "stat" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 101, + "panels": [], + "title": "📊 Throughput & Query Activity", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 6 + }, + "id": 10, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_sql_transactions_pooled_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\", }[$__rate_interval])", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "SQL Transactions Pooled / sec", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 6 + }, + "id": 11, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_queries_pooled_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval])", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "SQL Queries Pooled / sec", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Total SQL requests pooled by pgbouncer per second.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ops" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 12, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_queries_pooled_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval])", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Total Requests (queries) / sec", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "Bps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 22 + }, + "id": 13, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_received_bytes_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval])", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Network Received (bytes/sec)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "Bps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 22 + }, + "id": 14, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_sent_bytes_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval])", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Network Sent (bytes/sec)", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 30 + }, + "id": 102, + "panels": [], + "title": "⏱️ Latency & Wait Times", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Rate of total time spent executing queries against PostgreSQL.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 0, + "y": 31 + }, + "id": 20, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_queries_duration_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval])", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Query Duration Rate (sec/sec)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Rate of time connected to PostgreSQL in a transaction (idle-in-txn + executing).", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 8, + "y": 31 + }, + "id": 21, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_server_in_transaction_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval])", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Server In-Transaction Time Rate (sec/sec)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Rate of total time clients spend waiting for a server. THE key metric for pool saturation.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 8, + "x": 16, + "y": 31 + }, + "id": 22, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_client_wait_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval])", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Client Wait Time Rate (sec/sec) ⚠️", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Average time per query, derived from counters.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 39 + }, + "id": 23, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_queries_duration_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) / (rate(pgbouncer_stats_totals_queries_pooled_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) > 0)", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Avg Query Duration (query_duration / query_count)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Average time per transaction, derived from counters.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 39 + }, + "id": 24, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_server_in_transaction_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) / (rate(pgbouncer_stats_totals_sql_transactions_pooled_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) > 0)", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Avg Transaction Duration (xact_time / xact_count)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Average time a client waits before its query can be executed.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 47 + }, + "id": 25, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_client_wait_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) / (rate(pgbouncer_stats_totals_queries_pooled_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) > 0)", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Avg Client Wait per Request (wait_time / queries)", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 55 + }, + "id": 103, + "panels": [], + "title": "👤 Client Connections (Pools)", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Client connections linked to a server connection and able to process queries.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 56 + }, + "id": 30, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_pools_client_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ database }} / {{ user }}", + "range": true, + "refId": "A" + } + ], + "title": "Client Active Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Clients waiting on a server connection. Non-zero = pool saturation.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 56 + }, + "id": 31, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_pools_client_waiting_cancel_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ database }} / {{ user }}", + "range": true, + "refId": "A" + } + ], + "title": "Client Waiting Connections ⚠️", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Client connections to pgBouncer broken down by application_name and state.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 65 + }, + "id": 107, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "editorMode": "code", + "expr": "sum by (application_name, state) (pgbouncer_client_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "{{ application_name }} / {{ state }}", + "range": true, + "refId": "A" + } + ], + "title": "Client Connections by Application Name & State", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Age of the oldest unserved client connection. High values = serious pool exhaustion.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 74 + }, + "id": 32, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_pools_client_maxwait_seconds{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ database }} / {{ user }}", + "range": true, + "refId": "A" + } + ], + "title": "Client Max Wait (oldest unserved client) ⚠️", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 83 + }, + "id": 104, + "panels": [], + "title": "🖥️ Server Connections (Pools)", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Server connections linked to a client and processing queries.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 84 + }, + "id": 40, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_pools_server_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ database }} / {{ user }}", + "range": true, + "refId": "A" + } + ], + "title": "Server Active Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Server connections idle and ready for a client query.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 20, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 84 + }, + "id": 41, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_pools_server_idle_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ database }} / {{ user }}", + "range": true, + "refId": "A" + } + ], + "title": "Server Idle Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Server connections idle > server_check_delay, needing server_check_query before reuse.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 0, + "y": 93 + }, + "id": 42, + "options": { + "legend": { + "calcs": ["lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_pools_server_used_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ database }} / {{ user }}", + "range": true, + "refId": "A" + } + ], + "title": "Server Used Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Server connections currently running server_reset_query or server_check_query.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 8, + "y": 93 + }, + "id": 43, + "options": { + "legend": { + "calcs": ["lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_pools_server_testing_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ database }} / {{ user }}", + "range": true, + "refId": "A" + } + ], + "title": "Server Testing Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Server connections currently logging in to PostgreSQL.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 8, + "x": 16, + "y": 93 + }, + "id": 44, + "options": { + "legend": { + "calcs": ["lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_pools_server_login_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ database }} / {{ user }}", + "range": true, + "refId": "A" + } + ], + "title": "Server Login Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "bars", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "active" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "green", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "idle" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "used" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "yellow", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "testing" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "orange", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "login" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "purple", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 9, + "w": 24, + "x": 0, + "y": 102 + }, + "id": 45, + "options": { + "legend": { + "calcs": ["lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "sum(pgbouncer_pools_server_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "active", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "sum(pgbouncer_pools_server_idle_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "idle", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "sum(pgbouncer_pools_server_used_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "used", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "sum(pgbouncer_pools_server_testing_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "testing", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "expr": "sum(pgbouncer_pools_server_login_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"})", + "legendFormat": "login", + "refId": "E" + } + ], + "title": "All Server Connection States (Aggregated)", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 111 + }, + "id": 105, + "panels": [], + "title": "🗄️ Database Configuration & Status", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 112 + }, + "id": 50, + "options": { + "legend": { + "calcs": ["lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_current_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ name }} current", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_max_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ name }} max", + "range": true, + "refId": "B" + } + ], + "title": "Database Current vs Max Connections", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "yellow", + "value": 0.7 + }, + { + "color": "red", + "value": 0.9 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 112 + }, + "id": 51, + "options": { + "minVizHeight": 75, + "minVizWidth": 75, + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "sizing": "auto" + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_current_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"} / (pgbouncer_databases_max_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"} > 0)", + "legendFormat": "{{ name }}", + "range": true, + "refId": "A" + } + ], + "title": "Database Connection Utilization (current/max)", + "type": "gauge" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 120 + }, + "id": 52, + "options": { + "legend": { + "calcs": ["lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_pool_size{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ name }} pool_size", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_reserve_pool{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ name }} reserve", + "range": true, + "refId": "B" + } + ], + "title": "Database Pool Size & Reserve Pool", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "0": { + "color": "green", + "text": "Active" + }, + "1": { + "color": "red", + "text": "PAUSED" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 12, + "y": 120 + }, + "id": 53, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_paused{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ name }}", + "range": true, + "refId": "A" + } + ], + "title": "Database Paused", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "0": { + "color": "green", + "text": "Enabled" + }, + "1": { + "color": "red", + "text": "DISABLED" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 6, + "x": 18, + "y": 120 + }, + "id": 55, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_disabled{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "legendFormat": "{{ name }}", + "range": true, + "refId": "A" + } + ], + "title": "Database Disabled", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "paused" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 1 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "disabled" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 1 + } + ] + } + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 128 + }, + "id": 54, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": ["sum"], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_pool_size{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "format": "table", + "instant": true, + "legendFormat": "", + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_reserve_pool{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "format": "table", + "instant": true, + "legendFormat": "", + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_max_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "format": "table", + "instant": true, + "legendFormat": "", + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_current_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "format": "table", + "instant": true, + "legendFormat": "", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_paused{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "format": "table", + "instant": true, + "legendFormat": "", + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "pgbouncer_databases_disabled{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}", + "format": "table", + "instant": true, + "legendFormat": "", + "refId": "F" + } + ], + "title": "Database Status Table", + "transformations": [ + { + "id": "seriesToColumns", + "options": { + "byField": "name" + } + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time 1": true, + "Time 2": true, + "Time 3": true, + "Time 4": true, + "Time 5": true, + "Time 6": true, + "__name__ 1": true, + "__name__ 2": true, + "__name__ 3": true, + "__name__ 4": true, + "__name__ 5": true, + "__name__ 6": true, + "database 1": true, + "database 2": true, + "database 3": true, + "database 4": true, + "database 5": true, + "database 6": true, + "force_user 1": true, + "force_user 2": true, + "force_user 3": true, + "force_user 4": true, + "force_user 5": true, + "force_user 6": true, + "host 1": true, + "host 2": true, + "host 3": true, + "host 4": true, + "host 5": true, + "host 6": true, + "instance 1": true, + "instance 2": true, + "instance 3": true, + "instance 4": true, + "instance 5": true, + "instance 6": true, + "job 1": true, + "job 2": true, + "job 3": true, + "job 4": true, + "job 5": true, + "job 6": true, + "pool_mode 1": true, + "pool_mode 2": true, + "pool_mode 3": true, + "pool_mode 4": true, + "pool_mode 5": true, + "pool_mode 6": true, + "port 1": true, + "port 2": true, + "port 3": true, + "port 4": true, + "port 5": true, + "port 6": true + }, + "renameByName": { + "Value #A": "pool_size", + "Value #B": "reserve_pool", + "Value #C": "max_connections", + "Value #D": "current_connections", + "Value #E": "paused", + "Value #F": "disabled" + } + } + } + ], + "type": "table" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 136 + }, + "id": 106, + "panels": [], + "title": "🔄 Pool Efficiency & Ratios", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "How many client connections share each server connection. Higher = more multiplexing.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 137 + }, + "id": 60, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "sum by (database) (pgbouncer_pools_client_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}) / (sum by (database) (pgbouncer_pools_server_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}) > 0)", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Client-to-Server Multiplexing Ratio", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Percentage of server connections actively serving clients vs sitting idle.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 137 + }, + "id": 61, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "sum by (database) (pgbouncer_pools_server_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\", }) / (sum by (database) (pgbouncer_pools_server_active_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"} + pgbouncer_pools_server_idle_connections{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}) > 0)", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Server Pool Utilization (active / (active+idle))", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "description": "Proportion of time waiting vs executing. Values near 1 = severe contention.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "scheme", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 2, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 145 + }, + "id": 62, + "options": { + "legend": { + "calcs": ["mean", "max", "lastNotNull"], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "12.0.2", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "editorMode": "code", + "expr": "rate(pgbouncer_stats_totals_client_wait_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) / (rate(pgbouncer_stats_totals_client_wait_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) + rate(pgbouncer_stats_totals_queries_duration_seconds_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}[$__rate_interval]) > 0)", + "legendFormat": "{{ database }}", + "range": true, + "refId": "A" + } + ], + "title": "Wait Time vs Query Time Ratio", + "type": "timeseries" + } + ], + "preload": false, + "refresh": "30s", + "schemaVersion": 41, + "tags": ["pgbouncer", "postgresql", "database", "connection-pooling"], + "templating": { + "list": [ + { + "current": { + "text": "All", + "value": ["$__all"] + }, + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "includeAll": true, + "label": "Instance", + "multi": true, + "name": "instance", + "options": [], + "query": { + "query": "label_values(pgbouncer_up{job=\"discovered-internal-storage-pgbouncer\"}, instance)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 1, + "type": "query" + }, + { + "current": { + "text": "All", + "value": "$__all" + }, + "datasource": { + "type": "prometheus", + "uid": "local_prometheus" + }, + "includeAll": true, + "label": "Database", + "multi": true, + "name": "database", + "options": [], + "query": { + "query": "label_values(pgbouncer_stats_queries_pooled_total{job=\"discovered-internal-storage-pgbouncer\", instance=~\"$instance\"}, database)", + "refId": "StandardVariableQuery" + }, + "refresh": 2, + "regex": "", + "sort": 1, + "type": "query" + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": {}, + "timezone": "utc", + "title": "Storage - PgBouncer Overview", + "uid": "storage-pgbouncer", + "version": 2 +} diff --git a/src/config.ts b/src/config.ts index 84506f6c..d9a78444 100644 --- a/src/config.ts +++ b/src/config.ts @@ -102,7 +102,6 @@ type StorageConfigType = { databaseEnableQueryCancellation: boolean databaseStatementTimeout: number databaseApplicationName: string - pgQueueApplicationName: string region: string requestTraceHeader?: string requestEtagHeaders: string[] @@ -442,10 +441,6 @@ export function getConfig(options?: { reload?: boolean }): StorageConfigType { databaseApplicationName: getOptionalConfigFromEnv('DATABASE_APPLICATION_NAME') || `Supabase Storage API ${getOptionalConfigFromEnv('VERSION') || '0.0.0'}`, - pgQueueApplicationName: - getOptionalConfigFromEnv('PG_QUEUE_APPLICATION_NAME') || - `Supabase Storage PgBoss ${getOptionalConfigFromEnv('VERSION') || '0.0.0'}`, - // CDN cdnPurgeEndpointURL: getOptionalConfigFromEnv('CDN_PURGE_ENDPOINT_URL'), cdnPurgeEndpointKey: getOptionalConfigFromEnv('CDN_PURGE_ENDPOINT_KEY'), diff --git a/src/internal/queue/database.ts b/src/internal/queue/database.ts index f4b343cb..2acffa2a 100644 --- a/src/internal/queue/database.ts +++ b/src/internal/queue/database.ts @@ -3,7 +3,6 @@ import { ERRORS } from '@internal/errors' import { Knex } from 'knex' import pg from 'pg' import { Db } from 'pg-boss' -import { getConfig } from '../../config' export class QueueDB extends EventEmitter implements Db { opened = false @@ -16,9 +15,6 @@ export class QueueDB extends EventEmitter implements Db { constructor(config: pg.PoolConfig) { super() - - config.application_name = config.application_name || getConfig().pgQueueApplicationName - this.config = config } diff --git a/src/internal/queue/queue.ts b/src/internal/queue/queue.ts index 102fc700..7cf96cb3 100644 --- a/src/internal/queue/queue.ts +++ b/src/internal/queue/queue.ts @@ -91,6 +91,7 @@ export abstract class Queue { pgQueueReadWriteTimeout, pgQueueConcurrentTasksPerQueue, pgQueueMaxConnections, + databaseApplicationName, } = getConfig() let url = pgQueueConnectionURL || databaseURL @@ -108,6 +109,7 @@ export abstract class Queue { min: 0, max: pgQueueMaxConnections, connectionString: url, + application_name: databaseApplicationName, statement_timeout: pgQueueReadWriteTimeout > 0 ? pgQueueReadWriteTimeout : undefined, })