{
  "dashboard": {
    "title": "AgentDB Observability Dashboard",
    "tags": ["agentdb", "observability"],
    "timezone": "browser",
    "panels": [
      {
        "title": "Query Latency",
        "type": "graph",
        "targets": [
          {
            "expr": "histogram_quantile(0.95, sum(rate(agentdb_query_latency_bucket[5m])) by (le, operation_type))",
            "legendFormat": "p95 - {{operation_type}}"
          },
          {
            "expr": "histogram_quantile(0.99, sum(rate(agentdb_query_latency_bucket[5m])) by (le, operation_type))",
            "legendFormat": "p99 - {{operation_type}}"
          }
        ],
        "gridPos": {
          "x": 0,
          "y": 0,
          "w": 12,
          "h": 8
        }
      },
      {
        "title": "Cache Hit Rate",
        "type": "gauge",
        "targets": [
          {
            "expr": "agentdb_cache_hit_rate"
          }
        ],
        "gridPos": {
          "x": 12,
          "y": 0,
          "w": 6,
          "h": 8
        },
        "options": {
          "min": 0,
          "max": 100,
          "thresholds": [
            { "value": 0, "color": "red" },
            { "value": 50, "color": "yellow" },
            { "value": 80, "color": "green" }
          ]
        }
      },
      {
        "title": "Error Rate",
        "type": "graph",
        "targets": [
          {
            "expr": "sum(rate(agentdb_errors[5m])) by (error_type)",
            "legendFormat": "{{error_type}}"
          }
        ],
        "gridPos": {
          "x": 18,
          "y": 0,
          "w": 6,
          "h": 8
        }
      },
      {
        "title": "Operations Throughput",
        "type": "graph",
        "targets": [
          {
            "expr": "sum(rate(agentdb_operations[1m])) by (operation_type)",
            "legendFormat": "{{operation_type}}"
          }
        ],
        "gridPos": {
          "x": 0,
          "y": 8,
          "w": 12,
          "h": 8
        }
      },
      {
        "title": "Cache Statistics",
        "type": "stat",
        "targets": [
          {
            "expr": "sum(rate(agentdb_cache_hits[5m]))",
            "legendFormat": "Hits/sec"
          },
          {
            "expr": "sum(rate(agentdb_cache_misses[5m]))",
            "legendFormat": "Misses/sec"
          }
        ],
        "gridPos": {
          "x": 12,
          "y": 8,
          "w": 12,
          "h": 8
        }
      },
      {
        "title": "Query Latency by Table",
        "type": "heatmap",
        "targets": [
          {
            "expr": "sum(rate(agentdb_query_latency_bucket[5m])) by (le, table_name)",
            "format": "heatmap"
          }
        ],
        "gridPos": {
          "x": 0,
          "y": 16,
          "w": 24,
          "h": 8
        }
      }
    ],
    "refresh": "5s",
    "time": {
      "from": "now-1h",
      "to": "now"
    }
  }
}
