{
  "uid": "vigilcare-v1",
  "title": "VigilCare Clinical",
  "tags": ["vigilcare", "clinical", "prometheus"],
  "timezone": "browser",
  "schemaVersion": 38,
  "version": 1,
  "refresh": "30s",
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "panels": [
    {
      "id": 1,
      "type": "stat",
      "title": "Unacknowledged Critical Alerts",
      "gridPos": { "x": 0, "y": 0, "w": 6, "h": 4 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "alerts_unacknowledged_gauge",
          "legendFormat": "open > 5 min",
          "refId": "A"
        }
      ],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "reduceOptions": {
          "values": false,
          "calcs": ["lastNotNull"],
          "fields": ""
        }
      },
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "red", "value": 1 }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "id": 2,
      "type": "timeseries",
      "title": "Observation Ingest Rate",
      "gridPos": { "x": 6, "y": 0, "w": 12, "h": 8 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "rate(observations_ingested_total[1m])",
          "legendFormat": "{{observation_code}} / {{source}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 3,
      "type": "bargauge",
      "title": "Clinical Alerts by Type and Severity (5m)",
      "gridPos": { "x": 18, "y": 0, "w": 6, "h": 8 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "increase(clinical_alerts_total[5m])",
          "legendFormat": "{{alert_type}} / {{severity}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Outbox Pending Events",
      "gridPos": { "x": 0, "y": 8, "w": 6, "h": 4 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "outbox_pending_events",
          "legendFormat": "pending",
          "refId": "A"
        }
      ],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "reduceOptions": {
          "values": false,
          "calcs": ["lastNotNull"],
          "fields": ""
        }
      },
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 100 },
              { "color": "red", "value": 500 }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "id": 5,
      "type": "timeseries",
      "title": "Kafka Consumer Lag by Group",
      "gridPos": { "x": 6, "y": 8, "w": 12, "h": 8 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "kafka_consumer_lag",
          "legendFormat": "{{consumer_group}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 6,
      "type": "timeseries",
      "title": "Ingest Latency p50 / p99",
      "gridPos": { "x": 18, "y": 8, "w": 6, "h": 8 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "histogram_quantile(0.50, rate(observation_ingest_duration_seconds_bucket[5m]))",
          "legendFormat": "p50",
          "refId": "A"
        },
        {
          "expr": "histogram_quantile(0.99, rate(observation_ingest_duration_seconds_bucket[5m]))",
          "legendFormat": "p99",
          "refId": "B"
        }
      ]
    },
    {
      "id": 7,
      "type": "stat",
      "title": "Escalations Total",
      "gridPos": { "x": 0, "y": 12, "w": 12, "h": 4 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "escalations_total",
          "legendFormat": "escalations",
          "refId": "A"
        }
      ],
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "reduceOptions": {
          "values": false,
          "calcs": ["lastNotNull"],
          "fields": ""
        }
      }
    },
    {
      "id": 8,
      "type": "stat",
      "title": "SIRS Detections Total",
      "gridPos": { "x": 12, "y": 12, "w": 12, "h": 4 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "sirs_detections_total",
          "legendFormat": "sirs",
          "refId": "A"
        }
      ],
      "options": {
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "auto",
        "reduceOptions": {
          "values": false,
          "calcs": ["lastNotNull"],
          "fields": ""
        }
      }
    },
    {
      "id": 9,
      "type": "stat",
      "title": "Ward Gateways Offline",
      "description": "Gateways in DEGRADED or OFFLINE status",
      "gridPos": { "x": 0, "y": 16, "w": 6, "h": 4 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "sum(ward_gateways_offline_gauge)",
          "legendFormat": "offline/degraded",
          "refId": "A"
        }
      ],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "reduceOptions": {
          "values": false,
          "calcs": ["lastNotNull"],
          "fields": ""
        }
      },
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 1 },
              { "color": "red", "value": 2 }
            ]
          }
        },
        "overrides": []
      }
    },
    {
      "id": 10,
      "type": "bargauge",
      "title": "Gateway Buffer Depth",
      "gridPos": { "x": 6, "y": 16, "w": 12, "h": 6 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "ward_gateway_buffer_depth",
          "legendFormat": "{{gateway_code}} / {{department}}",
          "refId": "A"
        }
      ]
    },
    {
      "id": 11,
      "type": "timeseries",
      "title": "Clinical Sync Batches (5m rate)",
      "gridPos": { "x": 18, "y": 16, "w": 6, "h": 6 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "rate(clinical_sync_batches_total[5m])",
          "legendFormat": "{{status}}",
          "refId": "A"
        },
        {
          "expr": "histogram_quantile(0.95, rate(clinical_sync_batch_duration_seconds_bucket[5m]))",
          "legendFormat": "p95 duration",
          "refId": "B"
        }
      ]
    },
    {
      "id": 12,
      "type": "stat",
      "title": "Total Sync Backlog (buffer depth sum)",
      "gridPos": { "x": 0, "y": 20, "w": 6, "h": 4 },
      "datasource": { "type": "prometheus", "uid": "prometheus" },
      "targets": [
        {
          "expr": "sum(ward_gateway_buffer_depth)",
          "legendFormat": "pending events",
          "refId": "A"
        }
      ],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "reduceOptions": {
          "values": false,
          "calcs": ["lastNotNull"],
          "fields": ""
        }
      },
      "fieldConfig": {
        "defaults": {
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 100 },
              { "color": "red", "value": 500 }
            ]
          }
        },
        "overrides": []
      }
    }
  ]
}
