{
  "dashboard": {
    "title": "Coordination Protocol Health",
    "uid": "coordination-health",
    "timezone": "browser",
    "panels": [
      {
        "id": 1,
        "title": "Redis Connection Status",
        "type": "stat",
        "gridPos": {"h": 8, "w": 6, "x": 0, "y": 0},
        "targets": [
          {
            "expr": "redis_connected_clients",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "short",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "red", "value": null},
                {"color": "yellow", "value": 1},
                {"color": "green", "value": 5}
              ]
            }
          }
        }
      },
      {
        "id": 2,
        "title": "Queue Depth (Messages)",
        "type": "stat",
        "gridPos": {"h": 8, "w": 6, "x": 6, "y": 0},
        "targets": [
          {
            "expr": "redis_queue_size",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "short",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 500},
                {"color": "red", "value": 1000}
              ]
            }
          }
        }
      },
      {
        "id": 3,
        "title": "Message Delivery Success Rate",
        "type": "stat",
        "gridPos": {"h": 8, "w": 6, "x": 12, "y": 0},
        "targets": [
          {
            "expr": "sum(rate(coordination_messages_delivered_total[5m])) / sum(rate(coordination_messages_sent_total[5m]))",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "percentunit",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "red", "value": null},
                {"color": "yellow", "value": 0.95},
                {"color": "green", "value": 0.999}
              ]
            }
          }
        }
      },
      {
        "id": 4,
        "title": "Protocol Latency (ms)",
        "type": "stat",
        "gridPos": {"h": 8, "w": 6, "x": 18, "y": 0},
        "targets": [
          {
            "expr": "histogram_quantile(0.95, rate(coordination_protocol_latency_seconds_bucket[5m])) * 1000",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "ms",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 100},
                {"color": "red", "value": 500}
              ]
            }
          }
        }
      },
      {
        "id": 5,
        "title": "Message Throughput (msg/sec)",
        "type": "graph",
        "gridPos": {"h": 8, "w": 12, "x": 0, "y": 8},
        "targets": [
          {
            "expr": "sum(rate(coordination_messages_total[1m]))",
            "refId": "A",
            "legendFormat": "Msg/sec"
          }
        ]
      },
      {
        "id": 6,
        "title": "Redis Memory Usage",
        "type": "gauge",
        "gridPos": {"h": 8, "w": 12, "x": 12, "y": 8},
        "targets": [
          {
            "expr": "redis_memory_used_bytes / redis_memory_max_bytes * 100",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "percent",
            "thresholds": {
              "mode": "absolute",
              "steps": [
                {"color": "green", "value": null},
                {"color": "yellow", "value": 70},
                {"color": "red", "value": 85}
              ]
            }
          }
        }
      },
      {
        "id": 7,
        "title": "Failed Messages by Type",
        "type": "piechart",
        "gridPos": {"h": 8, "w": 12, "x": 0, "y": 16},
        "targets": [
          {
            "expr": "sum by (message_type) (rate(coordination_messages_failed_total[5m]))",
            "refId": "A"
          }
        ]
      },
      {
        "id": 8,
        "title": "Agent Coordination Status",
        "type": "table",
        "gridPos": {"h": 8, "w": 12, "x": 12, "y": 16},
        "targets": [
          {
            "expr": "coordination_agent_status",
            "format": "table",
            "instant": true,
            "refId": "A"
          }
        ],
        "transformations": [
          {
            "id": "organize",
            "options": {
              "excludeByName": {},
              "indexByName": {},
              "renameByName": {}
            }
          }
        ]
      }
    ],
    "refresh": "30s",
    "schemaVersion": 27,
    "style": "dark",
    "time": {
      "from": "now-1h",
      "to": "now"
    }
  }
}
