{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "Prometheus datasource that scrapes the DocStack API and worker",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "annotations": {
    "list": []
  },
  "description": "Bounded-cardinality operational signals for DocStack's visual execution plane. No data is unknown, not healthy: verify the worker target and instrumentation canary before interpreting an empty panel.",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "id": null,
  "links": [
    {
      "asDropdown": false,
      "icon": "external link",
      "includeVars": false,
      "keepTime": true,
      "tags": [],
      "targetBlank": true,
      "title": "Vision operations runbook",
      "type": "link",
      "url": "https://github.com/mssaleh/2pz-ocr/blob/main/docs/vision-operations-runbook.md"
    }
  ],
  "liveNow": false,
  "panels": [
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "description": "A discovered worker target must remain scrapeable. An empty result means discovery is not configured and must not be interpreted as healthy.",
      "fieldConfig": {
        "defaults": {
          "color": {"mode": "thresholds"},
          "mappings": [
            {"options": {"0": {"color": "red", "text": "DOWN"}, "1": {"color": "green", "text": "UP"}}, "type": "value"}
          ],
          "thresholds": {"mode": "absolute", "steps": [{"color": "red", "value": null}, {"color": "green", "value": 1}]}
        },
        "overrides": []
      },
      "gridPos": {"h": 4, "w": 6, "x": 0, "y": 0},
      "id": 1,
      "options": {"colorMode": "background", "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "reduceOptions": {"calcs": ["lastNotNull"], "fields": "", "values": false}, "textMode": "auto", "wideLayout": true},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "min(up{docstack_component=\"worker\"})", "instant": true, "legendFormat": "worker scrape", "range": false, "refId": "A"}
      ],
      "title": "Worker metrics target",
      "type": "stat"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "description": "If this panel and the traffic panels remain empty after the promotion canary, stop the rollout and verify production recorder wiring.",
      "gridPos": {"h": 4, "w": 18, "x": 6, "y": 0},
      "id": 2,
      "options": {"content": "## Telemetry interpretation\n\n**No data is unknown, not healthy.** First verify `up{docstack_component=\"worker\"}`, then run the bounded canary in the runbook and confirm every expected metric family increments. Prometheus labels contain only bounded contract values; use the access-controlled diagnostics view for job-level evidence.", "mode": "markdown"},
      "pluginVersion": "11.0.0",
      "title": "Read this first",
      "type": "text"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "results/s", "axisPlacement": "auto", "barAlignment": 0, "drawStyle": "line", "fillOpacity": 8, "gradientMode": "none", "hideFrom": {"legend": false, "tooltip": false, "viz": false}, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, "scaleDistribution": {"type": "linear"}, "showPoints": "never", "spanNulls": false, "stacking": {"group": "A", "mode": "normal"}, "thresholdsStyle": {"mode": "off"}}, "min": 0}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 0, "y": 4},
      "id": 3,
      "options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum by (engine, role, status) (rate(docstack_vision_engine_results_total[$__rate_interval]))", "legendFormat": "{{engine}} / {{role}} / {{status}}", "range": true, "refId": "A"}
      ],
      "title": "Engine result throughput",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "description": "Volume-gated alert thresholds are 5% failures and 10% partial results.",
      "fieldConfig": {"defaults": {"color": {"mode": "thresholds"}, "decimals": 1, "max": 1, "min": 0, "thresholds": {"mode": "absolute", "steps": [{"color": "green", "value": null}, {"color": "yellow", "value": 0.05}, {"color": "red", "value": 0.1}]}, "unit": "percentunit"}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 12, "y": 4},
      "id": 4,
      "options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum(rate(docstack_vision_engine_results_total{status=~\"failed|rejected\"}[$__rate_interval])) / clamp_min(sum(rate(docstack_vision_engine_results_total[$__rate_interval])), 0.000000001)", "legendFormat": "failed or rejected", "range": true, "refId": "A"},
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum(rate(docstack_vision_engine_results_total{status=\"partial\"}[$__rate_interval])) / clamp_min(sum(rate(docstack_vision_engine_results_total[$__rate_interval])), 0.000000001)", "legendFormat": "partial", "range": true, "refId": "B"}
      ],
      "title": "Failure and partial-result ratios",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"drawStyle": "line", "fillOpacity": 5, "lineWidth": 1, "pointSize": 5, "showPoints": "never", "spanNulls": false}, "min": 0, "unit": "s"}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 0, "y": 12},
      "id": 5,
      "options": {"legend": {"calcs": ["lastNotNull", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "histogram_quantile(0.95, sum by (le, format, profile) (rate(docstack_vision_render_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "render p95 {{format}} / {{profile}}", "range": true, "refId": "A"},
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "histogram_quantile(0.95, sum by (le, lane, role) (rate(docstack_vision_lane_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "lane p95 {{lane}} / {{role}}", "range": true, "refId": "B"}
      ],
      "title": "Render and lane p95 latency",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"drawStyle": "line", "fillOpacity": 8, "lineWidth": 1, "pointSize": 5, "showPoints": "never", "spanNulls": false}, "min": 0, "unit": "ops"}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 12, "y": 12},
      "id": 6,
      "options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum by (format, profile, kind) (rate(docstack_vision_render_surfaces_total[$__rate_interval]))", "legendFormat": "surfaces {{format}} / {{profile}} / {{kind}}", "range": true, "refId": "A"},
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum by (format, profile, code) (rate(docstack_vision_render_warnings_total[$__rate_interval]))", "legendFormat": "warnings {{format}} / {{profile}} / {{code}}", "range": true, "refId": "B"},
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum by (format, profile) (rate(docstack_vision_render_pixels_total[$__rate_interval]))", "legendFormat": "pixels {{format}} / {{profile}}", "range": true, "refId": "C"}
      ],
      "title": "Render surfaces, pixels, and warnings per second",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"drawStyle": "line", "fillOpacity": 8, "lineWidth": 1, "pointSize": 5, "showPoints": "never", "spanNulls": false}, "min": 0}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 0, "y": 20},
      "id": 7,
      "options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum by (engine, task, status) (rate(docstack_vision_crop_rescues_total[$__rate_interval]))", "legendFormat": "rescues/s {{engine}} / {{task}} / {{status}}", "range": true, "refId": "A"},
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "histogram_quantile(0.95, sum by (le, task) (rate(docstack_vision_crop_area_pixels_bucket[$__rate_interval])))", "legendFormat": "area p95 {{task}}", "range": true, "refId": "B"}
      ],
      "title": "Targeted crop rescue activity and area",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"drawStyle": "line", "fillOpacity": 8, "lineWidth": 1, "pointSize": 5, "showPoints": "never", "spanNulls": false}, "min": 0, "unit": "ops"}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 12, "y": 20},
      "id": 8,
      "options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum by (phase, kind, severity, outcome, action) (rate(docstack_vision_quality_signals_total[$__rate_interval]))", "legendFormat": "{{phase}} / {{kind}} / {{severity}} / {{outcome}} / {{action}}", "range": true, "refId": "A"}
      ],
      "title": "Quality signals by outcome and action",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"drawStyle": "line", "fillOpacity": 8, "lineWidth": 1, "pointSize": 5, "showPoints": "never", "spanNulls": false}, "min": 0, "unit": "ops"}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 0, "y": 28},
      "id": 9,
      "options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum by (kind, state) (rate(docstack_vision_reconciliation_decisions_total[$__rate_interval]))", "legendFormat": "{{kind}} / {{state}}", "range": true, "refId": "A"}
      ],
      "title": "Evidence reconciliation decisions",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"drawStyle": "line", "fillOpacity": 8, "lineWidth": 1, "pointSize": 5, "showPoints": "never", "spanNulls": false}, "min": 0, "unit": "ops"}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 12, "y": 28},
      "id": 10,
      "options": {"legend": {"calcs": ["lastNotNull"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "sum by (decision, reason) (rate(docstack_vision_review_decisions_total[$__rate_interval]))", "legendFormat": "{{decision}} / {{reason}}", "range": true, "refId": "A"}
      ],
      "title": "Final review routing",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"drawStyle": "line", "fillOpacity": 5, "lineWidth": 1, "pointSize": 5, "showPoints": "never", "spanNulls": false}, "min": 0}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 0, "y": 36},
      "id": 11,
      "options": {"legend": {"calcs": ["lastNotNull", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "histogram_quantile(0.95, sum by (le, engine, resource, unit) (rate(docstack_vision_resource_measurement_bucket{resource=~\"queue_time|cpu_time|gpu_time\"}[$__rate_interval])))", "legendFormat": "{{engine}} / {{resource}} ({{unit}})", "range": true, "refId": "A"}
      ],
      "title": "Queue, CPU, and GPU time p95",
      "type": "timeseries"
    },
    {
      "datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"},
      "fieldConfig": {"defaults": {"color": {"mode": "palette-classic"}, "custom": {"drawStyle": "line", "fillOpacity": 5, "lineWidth": 1, "pointSize": 5, "showPoints": "never", "spanNulls": false}, "min": 0}, "overrides": []},
      "gridPos": {"h": 8, "w": 12, "x": 12, "y": 36},
      "id": 12,
      "options": {"legend": {"calcs": ["lastNotNull", "max"], "displayMode": "table", "placement": "bottom", "showLegend": true}, "tooltip": {"mode": "multi", "sort": "desc"}},
      "targets": [
        {"datasource": {"type": "prometheus", "uid": "${DS_PROMETHEUS}"}, "editorMode": "code", "expr": "histogram_quantile(0.95, sum by (le, engine, resource, unit) (rate(docstack_vision_resource_measurement_bucket{resource=~\"cpu_memory|gpu_memory|gpu_utilization|estimated_cost|input_pixels|output_tokens\"}[$__rate_interval])))", "legendFormat": "{{engine}} / {{resource}} ({{unit}})", "range": true, "refId": "A"}
      ],
      "title": "Memory, utilization, pixels, tokens, and cost p95",
      "type": "timeseries"
    }
  ],
  "refresh": "30s",
  "schemaVersion": 39,
  "tags": ["docstack", "vision", "worker", "operations"],
  "templating": {"list": []},
  "time": {"from": "now-6h", "to": "now"},
  "timepicker": {},
  "timezone": "browser",
  "title": "DocStack Vision Operations",
  "uid": "docstack-vision-operations",
  "version": 1,
  "weekStart": ""
}
