{
    "annotations": {
        "list": [
            {
                "builtIn": 1,
                "datasource": {
                    "type": "grafana",
                    "uid": "-- Grafana --"
                },
                "enable": true,
                "hide": true,
                "iconColor": "rgba(0, 211, 255, 1)",
                "name": "Annotations & Alerts",
                "target": {
                    "limit": 100,
                    "matchAny": false,
                    "tags": [],
                    "type": "dashboard"
                },
                "type": "dashboard"
            }
        ]
    },
    "description": "Overview dashboard for pgagroal connection pooler. Shows overall status, connections, session time, and server health.",
    "editable": true,
    "fiscalYearStartMonth": 0,
    "graphTooltip": 1,
    "id": null,
    "links": [
        {
            "asDropdown": true,
            "icon": "dashboard",
            "includeVars": true,
            "keepTime": true,
            "tags": [
                "pgagroal"
            ],
            "targetBlank": false,
            "title": "pgagroal Dashboards",
            "type": "dashboards"
        }
    ],
    "liveNow": false,
    "panels": [
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 0
            },
            "id": 100,
            "panels": [],
            "title": "System Status",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Overall pgagroal service status",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "mappings": [
                        {
                            "options": {
                                "0": {
                                    "color": "red",
                                    "index": 1,
                                    "text": "DOWN"
                                },
                                "1": {
                                    "color": "green",
                                    "index": 0,
                                    "text": "UP"
                                },
                                "2": {
                                    "color": "yellow",
                                    "index": 2,
                                    "text": "GRACEFUL"
                                }
                            },
                            "type": "value"
                        }
                    ],
                    "noValue": "Unknown",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "red",
                                "value": null
                            },
                            {
                                "color": "green",
                                "value": 1
                            }
                        ]
                    }
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 4,
                "x": 0,
                "y": 1
            },
            "id": 1,
            "options": {
                "colorMode": "background",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_state",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "pgagroal Status",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Pipeline mode (0=Performance, 1=Session, 2=Transaction)",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "mappings": [
                        {
                            "options": {
                                "0": {
                                    "color": "blue",
                                    "index": 0,
                                    "text": "Performance"
                                },
                                "1": {
                                    "color": "green",
                                    "index": 1,
                                    "text": "Session"
                                },
                                "2": {
                                    "color": "purple",
                                    "index": 2,
                                    "text": "Transaction"
                                }
                            },
                            "type": "value"
                        }
                    ],
                    "noValue": "Unknown",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "text",
                                "value": null
                            }
                        ]
                    }
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 4,
                "x": 4,
                "y": 1
            },
            "id": 2,
            "options": {
                "colorMode": "value",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_pipeline_mode",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "Pipeline Mode",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Number of servers that have failed",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "mappings": [],
                    "noValue": "0",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 1
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 4,
                "x": 8,
                "y": 1
            },
            "id": 3,
            "options": {
                "colorMode": "value",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_failed_servers",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "Failed Servers",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Maximum configured connections",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "mappings": [],
                    "noValue": "0",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "text",
                                "value": null
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 4,
                "x": 12,
                "y": 1
            },
            "id": 4,
            "options": {
                "colorMode": "value",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_max_connections",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "Max Connections",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Total connections in the pool",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "mappings": [],
                    "noValue": "0",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "text",
                                "value": null
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 4,
                "x": 16,
                "y": 1
            },
            "id": 5,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_total_connections",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "Total Connections",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Currently active connections",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "mappings": [],
                    "noValue": "0",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "yellow",
                                "value": 70
                            },
                            {
                                "color": "red",
                                "value": 90
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 4,
                "x": 20,
                "y": 1
            },
            "id": 6,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_active_connections",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "Active Connections",
            "type": "stat"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 6
            },
            "id": 101,
            "panels": [],
            "title": "Connection Overview",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "fieldConfig": {
                "defaults": {
                    "unit": "percentunit",
                    "min": 0,
                    "max": 1,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "#EAB839",
                                "value": 0.70
                            },
                            {
                                "color": "red",
                                "value": 0.90
                            }
                        ]
                    }
                }
            },
            "gridPos": {
                "h": 5,
                "w": 8,
                "x": 0,
                "y": 7
            },
            "id": 10,
            "options": {
                "showThresholdLabels": true,
                "showThresholdMarkers": true,
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "values": false
                },
                "orientation": "auto"
            },
            "targets": [
                {
                    "expr": "pgagroal_active_connections{instance=~\"$instance\"} / pgagroal_max_connections{instance=~\"$instance\"}",
                    "refId": "A"
                }
            ],
            "title": "Pool Saturation",
            "type": "gauge",
            "description": "Current pool utilization (Active / Max). Red > 90%."
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "fieldConfig": {
                "defaults": {
                    "unit": "ops",
                    "thresholds": {
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "yellow",
                                "value": 0.01
                            },
                            {
                                "color": "red",
                                "value": 0.1
                            }
                        ]
                    }
                }
            },
            "gridPos": {
                "h": 5,
                "w": 8,
                "x": 8,
                "y": 7
            },
            "id": 202,
            "options": {
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "values": false
                },
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto"
            },
            "targets": [
                {
                    "expr": "sum(rate(pgagroal_connection_error{instance=~\"$instance\"}[5m]) + rate(pgagroal_auth_user_error{instance=~\"$instance\"}[5m]))",
                    "refId": "A"
                }
            ],
            "title": "Total Error Rate (5m)",
            "type": "stat",
            "description": "Combined connection and authentication errors (5m moving avg)."
        },
        {
            "datasource": {
                "uid": "${DS_PROMETHEUS}"
            },
            "fieldConfig": {
                "defaults": {
                    "unit": "short",
                    "thresholds": {
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 1
                            }
                        ]
                    }
                }
            },
            "gridPos": {
                "h": 5,
                "w": 8,
                "x": 16,
                "y": 7
            },
            "id": 203,
            "options": {
                "colorMode": "background",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "values": false
                }
            },
            "targets": [
                {
                    "expr": "pgagroal_client_wait{instance=~\"$instance\"}",
                    "refId": "A"
                }
            ],
            "title": "Clients Waiting",
            "type": "stat",
            "description": "Number of clients currently waiting for a connection"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "axisCenteredZero": false,
                        "axisColorMode": "text",
                        "axisLabel": "",
                        "axisPlacement": "auto",
                        "barAlignment": 0,
                        "drawStyle": "line",
                        "fillOpacity": 20,
                        "gradientMode": "opacity",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "lineInterpolation": "smooth",
                        "lineWidth": 2,
                        "pointSize": 5,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "showPoints": "auto",
                        "spanNulls": false,
                        "stacking": {
                            "group": "A",
                            "mode": "none"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "mappings": [],
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Max Connections"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "red",
                                    "mode": "fixed"
                                }
                            },
                            {
                                "id": "custom.lineStyle",
                                "value": {
                                    "dash": [
                                        10,
                                        10
                                    ],
                                    "fill": "dash"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Active Connections"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "green",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Total Connections"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "blue",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Warning Threshold"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "yellow",
                                    "mode": "fixed"
                                }
                            },
                            {
                                "id": "custom.lineStyle",
                                "value": {
                                    "dash": [
                                        5,
                                        5
                                    ],
                                    "fill": "dash"
                                }
                            },
                            {
                                "id": "custom.lineWidth",
                                "value": 1
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Critical Threshold"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "red",
                                    "mode": "fixed"
                                }
                            },
                            {
                                "id": "custom.lineStyle",
                                "value": {
                                    "dash": [
                                        5,
                                        5
                                    ],
                                    "fill": "dash"
                                }
                            },
                            {
                                "id": "custom.lineWidth",
                                "value": 1
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 12
            },
            "id": 11,
            "options": {
                "legend": {
                    "calcs": [
                        "mean",
                        "max",
                        "last"
                    ],
                    "displayMode": "table",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_active_connections",
                    "legendFormat": "Active Connections",
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_total_connections",
                    "legendFormat": "Total Connections",
                    "refId": "B"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_max_connections",
                    "legendFormat": "Max Connections",
                    "refId": "C"
                },
                {
                    "datasource": {
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_max_connections * 0.7",
                    "legendFormat": "Warning Threshold",
                    "refId": "D"
                },
                {
                    "datasource": {
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_max_connections * 0.9",
                    "legendFormat": "Critical Threshold",
                    "refId": "E"
                }
            ],
            "title": "Connection State",
            "type": "timeseries",
            "description": "Active, total, and max connections over time with saturation thresholds."
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Histogram of session durations (seconds).",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "fixedColor": "green",
                        "mode": "fixed"
                    },
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            }
                        ]
                    }
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 6,
                "x": 12,
                "y": 12
            },
            "id": 12,
            "options": {
                "displayMode": "gradient",
                "minVizHeight": 10,
                "minVizWidth": 0,
                "orientation": "vertical",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "showUnfilled": false
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_session_time_seconds_bucket",
                    "format": "heatmap",
                    "legendFormat": "{{le}}",
                    "refId": "A"
                }
            ],
            "title": "Session Time Distribution (Seconds)",
            "type": "bargauge"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 15
            },
            "id": 102,
            "panels": [],
            "title": "Client Activity",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Number of waiting clients",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "mappings": [],
                    "noValue": "0",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "yellow",
                                "value": 5
                            },
                            {
                                "color": "red",
                                "value": 20
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 6,
                "x": 0,
                "y": 16
            },
            "id": 20,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_client_wait",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "Waiting Clients",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Number of active clients",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "mappings": [],
                    "noValue": "0",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "text",
                                "value": null
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 6,
                "x": 6,
                "y": 16
            },
            "id": 21,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_client_active",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "Active Clients",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Client waiting time",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "mappings": [],
                    "noValue": "0",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "yellow",
                                "value": 1
                            },
                            {
                                "color": "red",
                                "value": 5
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 5,
                "w": 6,
                "x": 12,
                "y": 16
            },
            "id": 22,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": [
                        "lastNotNull"
                    ],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "10.0.0",
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_wait_time",
                    "instant": true,
                    "refId": "A"
                }
            ],
            "title": "Wait Time",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Client state over time",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "axisCenteredZero": false,
                        "axisColorMode": "text",
                        "axisLabel": "",
                        "axisPlacement": "auto",
                        "barAlignment": 0,
                        "drawStyle": "line",
                        "fillOpacity": 20,
                        "gradientMode": "opacity",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "lineInterpolation": "smooth",
                        "lineWidth": 2,
                        "pointSize": 5,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "showPoints": "auto",
                        "spanNulls": false,
                        "stacking": {
                            "group": "A",
                            "mode": "none"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 21
            },
            "id": 23,
            "options": {
                "legend": {
                    "calcs": [
                        "mean",
                        "max",
                        "last"
                    ],
                    "displayMode": "table",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_client_active",
                    "legendFormat": "Active Clients",
                    "refId": "A"
                },
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_client_wait",
                    "legendFormat": "Waiting Clients",
                    "refId": "B"
                }
            ],
            "title": "Client State Over Time",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Client waiting time over time",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "axisCenteredZero": false,
                        "axisColorMode": "text",
                        "axisLabel": "",
                        "axisPlacement": "auto",
                        "barAlignment": 0,
                        "drawStyle": "line",
                        "fillOpacity": 20,
                        "gradientMode": "opacity",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "lineInterpolation": "smooth",
                        "lineWidth": 2,
                        "pointSize": 5,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "showPoints": "auto",
                        "spanNulls": false,
                        "stacking": {
                            "group": "A",
                            "mode": "none"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            }
                        ]
                    },
                    "unit": "s"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 21
            },
            "id": 24,
            "options": {
                "legend": {
                    "calcs": [
                        "mean",
                        "max",
                        "last"
                    ],
                    "displayMode": "table",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "desc"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "prometheus",
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "pgagroal_wait_time",
                    "legendFormat": "Wait Time",
                    "refId": "A"
                }
            ],
            "title": "Wait Time Over Time",
            "type": "timeseries"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 29
            },
            "id": 103,
            "panels": [],
            "title": "Logging",
            "type": "row"
        },
        {
            "datasource": {
                "type": "prometheus",
                "uid": "${DS_PROMETHEUS}"
            },
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "axisCenteredZero": false,
                        "axisColorMode": "text",
                        "axisLabel": "",
                        "axisPlacement": "auto",
                        "barAlignment": 0,
                        "drawStyle": "line",
                        "fillOpacity": 20,
                        "gradientMode": "opacity",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "lineInterpolation": "smooth",
                        "lineWidth": 2,
                        "pointSize": 5,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "showPoints": "auto",
                        "spanNulls": false,
                        "stacking": {
                            "group": "A",
                            "mode": "none"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Info"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "blue",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Warn"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "yellow",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Error"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "orange",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Fatal"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "red",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    }
                ]
            },
            "description": "Log entries emitted by pgagroal, grouped by severity. Sudden increases in Warn/Error/Fatal indicate misconfiguration or backend instability.",
            "gridPos": {
                "h": 8,
                "w": 24,
                "x": 0,
                "y": 30
            },
            "id": 30,
            "options": {
                "legend": {
                    "displayMode": "table",
                    "placement": "right",
                    "showLegend": true
                }
            },
            "targets": [
                {
                    "datasource": {
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "increase(pgagroal_logging_info{instance=~\"$instance\"}[$rate_interval])",
                    "legendFormat": "Info",
                    "refId": "A"
                },
                {
                    "datasource": {
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "increase(pgagroal_logging_warn{instance=~\"$instance\"}[$rate_interval])",
                    "legendFormat": "Warn",
                    "refId": "B"
                },
                {
                    "datasource": {
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "increase(pgagroal_logging_error{instance=~\"$instance\"}[$rate_interval])",
                    "legendFormat": "Error",
                    "refId": "C"
                },
                {
                    "datasource": {
                        "uid": "${DS_PROMETHEUS}"
                    },
                    "expr": "increase(pgagroal_logging_fatal{instance=~\"$instance\"}[$rate_interval])",
                    "legendFormat": "Fatal",
                    "refId": "D"
                }
            ],
            "title": "Log Levels",
            "type": "timeseries"
        },
        {
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 20
            },
            "id": 300,
            "title": "Historical Trends",
            "type": "row"
        },
        {
            "datasource": {
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Active vs waiting clients over time. Sustained waiting indicates pool saturation.",
            "fieldConfig": {
                "defaults": {
                    "unit": "short",
                    "min": 0,
                    "max": 10,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "orange",
                                "value": 1
                            },
                            {
                                "color": "red",
                                "value": 5
                            }
                        ]
                    },
                    "custom": {
                        "axisLabel": "clients",
                        "thresholdsStyle": {
                            "mode": "line"
                        }
                    }
                }
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 21
            },
            "id": 301,
            "options": {
                "legend": {
                    "displayMode": "table",
                    "placement": "bottom",
                    "showLegend": true
                }
            },
            "targets": [
                {
                    "expr": "pgagroal_client_wait{instance=~\"$instance\"}",
                    "legendFormat": "Clients Waiting",
                    "refId": "A"
                }
            ],
            "title": "Client State Over Time",
            "type": "timeseries"
        },
        {
            "datasource": {
                "uid": "${DS_PROMETHEUS}"
            },
            "description": "Per-second rate of connection and authentication errors (5m window).",
            "fieldConfig": {
                "defaults": {
                    "unit": "ops",
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 0.1
                            }
                        ]
                    },
                    "custom": {
                        "thresholdsStyle": {
                            "mode": "line"
                        }
                    }
                }
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 21
            },
            "id": 302,
            "options": {
                "legend": {
                    "displayMode": "table",
                    "placement": "bottom",
                    "showLegend": true
                }
            },
            "targets": [
                {
                    "expr": "rate(pgagroal_connection_error{instance=~\"$instance\"}[$rate_interval])",
                    "legendFormat": "Connection Error Rate",
                    "refId": "A"
                },
                {
                    "expr": "rate(pgagroal_auth_user_error{instance=~\"$instance\"}[$rate_interval])",
                    "legendFormat": "Auth Error Rate",
                    "refId": "B"
                }
            ],
            "title": "Error Rate Trends",
            "type": "timeseries"
        }
    ],
    "refresh": "30s",
    "schemaVersion": 39,
    "style": "dark",
    "tags": [
        "pgagroal",
        "overview"
    ],
    "templating": {
        "list": [
            {
                "name": "DS_PROMETHEUS",
                "type": "datasource",
                "label": "Prometheus",
                "query": "prometheus",
                "current": {},
                "hide": 0
            },
            {
                "name": "instance",
                "type": "query",
                "label": "Instance",
                "query": "label_values(pgagroal_state, instance)",
                "datasource": {
                    "type": "prometheus",
                    "uid": "${DS_PROMETHEUS}"
                },
                "multi": true,
                "includeAll": true,
                "allValue": ".*",
                "refresh": 1,
                "sort": 1,
                "current": {},
                "hide": 0
            },
            {
                "name": "rate_interval",
                "type": "interval",
                "label": "Rate Interval",
                "auto": true,
                "auto_count": 30,
                "auto_min": "1m",
                "query": "1m,5m,10m,15m,30m",
                "current": {
                    "text": "5m",
                    "value": "5m"
                },
                "hide": 0
            }
        ]
    },
    "time": {
        "from": "now-6h",
        "to": "now"
    },
    "timepicker": {
        "refresh_intervals": [
            "10s",
            "30s",
            "1m",
            "5m",
            "15m"
        ]
    },
    "timezone": "browser",
    "title": "pgagroal Overview",
    "uid": "pgagroal-overview",
    "version": 1,
    "weekStart": ""
}