{
  "dashboard": {
    "title": "SSE Streaming Metrics",
    "tags": ["sse", "streaming", "events"],
    "timezone": "browser",
    "panels": [
      {
        "id": 1,
        "title": "Active SSE Connections",
        "type": "graph",
        "targets": [
          {
            "expr": "shc_sse_connections",
            "legendFormat": "{{operation_type}}"
          }
        ],
        "yaxes": [
          {"label": "Connections", "format": "short"}
        ]
      },
      {
        "id": 2,
        "title": "Tracked Operations",
        "type": "graph",
        "targets": [
          {
            "expr": "shc_sse_operations",
            "legendFormat": "{{status}}"
          }
        ],
        "yaxes": [
          {"label": "Operations", "format": "short"}
        ]
      },
      {
        "id": 3,
        "title": "Event Emission Rate",
        "type": "graph",
        "targets": [
          {
            "expr": "rate(shc_sse_events_emitted_total[5m])",
            "legendFormat": "{{event_type}}"
          }
        ],
        "yaxes": [
          {"label": "Events/sec", "format": "short"}
        ]
      },
      {
        "id": 4,
        "title": "Event Latency (p95)",
        "type": "graph",
        "targets": [
          {
            "expr": "histogram_quantile(0.95, rate(shc_sse_event_latency_seconds_bucket[5m]))",
            "legendFormat": "{{event_type}}"
          }
        ],
        "yaxes": [
          {"label": "Latency (sec)", "format": "s"}
        ]
      },
      {
        "id": 5,
        "title": "Slow Client Detections",
        "type": "graph",
        "targets": [
          {
            "expr": "rate(shc_sse_slow_clients_total[5m])",
            "legendFormat": "Slow clients/sec"
          }
        ],
        "yaxes": [
          {"label": "Rate", "format": "short"}
        ]
      },
      {
        "id": 6,
        "title": "Events Dropped (Buffer Overflow)",
        "type": "graph",
        "targets": [
          {
            "expr": "rate(shc_sse_events_dropped_total[5m])",
            "legendFormat": "{{operation_id}}"
          }
        ],
        "yaxes": [
          {"label": "Events/sec", "format": "short"}
        ]
      },
      {
        "id": 7,
        "title": "Memory Usage",
        "type": "graph",
        "targets": [
          {
            "expr": "shc_sse_memory_bytes",
            "legendFormat": "Memory"
          }
        ],
        "yaxes": [
          {"label": "Bytes", "format": "bytes"}
        ],
        "alert": {
          "conditions": [
            {
              "evaluator": {
                "type": "gt",
                "params": [104857600]
              },
              "query": {"params": ["A", "5m", "now"]}
            }
          ],
          "name": "SSE Memory Usage High"
        }
      },
      {
        "id": 8,
        "title": "Events Buffered per Operation",
        "type": "graph",
        "targets": [
          {
            "expr": "shc_sse_events_buffered",
            "legendFormat": "{{operation_id}}"
          }
        ],
        "yaxes": [
          {"label": "Events", "format": "short"}
        ]
      }
    ],
    "refresh": "10s",
    "time": {
      "from": "now-1h",
      "to": "now"
    }
  }
}
