{
  "dashboard": {
    "id": null,
    "title": "PostgreSQL Monitoring",
    "tags": ["postgresql", "database", "monitoring"],
    "timezone": "browser",
    "panels": [
      {
        "id": 1,
        "title": "Database Connections",
        "type": "stat",
        "targets": [
          {
            "expr": "pg_stat_database_numbackends{datname!~\"template.*|postgres\"}",
            "legendFormat": "{{datname}}"
          }
        ]
      },
      {
        "id": 2,
        "title": "Active Connections",
        "type": "timeseries",
        "targets": [
          {
            "expr": "sum(pg_stat_database_numbackends) by (datname)",
            "legendFormat": "{{datname}}"
          }
        ]
      },
      {
        "id": 3,
        "title": "Database Size",
        "type": "timeseries",
        "targets": [
          {
            "expr": "pg_database_size{datname!~\"template.*\"}",
            "legendFormat": "{{datname}}"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "bytes"
          }
        }
      },
      {
        "id": 4,
        "title": "Transactions",
        "type": "timeseries",
        "targets": [
          {
            "expr": "rate(pg_stat_database_xact_commit[5m])",
            "legendFormat": "Commits {{datname}}"
          },
          {
            "expr": "rate(pg_stat_database_xact_rollback[5m])",
            "legendFormat": "Rollbacks {{datname}}"
          }
        ]
      }
    ],
    "time": {
      "from": "now-1h",
      "to": "now"
    }
  },
  "folderId": 0,
  "message": "PostgreSQL monitoring dashboard",
  "overwrite": false
}
