1{ 2 "uid": "factory-ai", 3 "title": "Factory — AI", 4 "tags": ["factory", "observability", "ai"], 5 "timezone": "browser", 6 "schemaVersion": 39, 7 "version": 1, 8 "editable": true, 9 "refresh": "30s", 10 "time": { "from": "now-6h", "to": "now" }, 11 "panels": [ 12 { 13 "id": 1, 14 "type": "stat", 15 "title": "Tokens / min (in, 5 m)", 16 "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, 17 "gridPos": { "h": 4, "w": 6, "x": 0, "y": 0 }, 18 "fieldConfig": { "defaults": { "unit": "short", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [] }, 19 "options": { "colorMode": "value", "graphMode": "area" }, 20 "targets": [ { "refId": "A", "expr": "sum by (model) (rate(ai_tokens_total{service_name=\"factory-api\", direction=\"in\"}[5m])) * 60", "legendFormat": "{{model}} in" } ] 21 }, 22 { 23 "id": 2, 24 "type": "stat", 25 "title": "Tokens / min (out, 5 m)", 26 "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, 27 "gridPos": { "h": 4, "w": 6, "x": 6, "y": 0 }, 28 "fieldConfig": { "defaults": { "unit": "short", "thresholds": { "mode": "absolute", "steps": [ { "color": "blue", "value": null } ] } }, "overrides": [] }, 29 "options": { "colorMode": "value", "graphMode": "area" }, 30 "targets": [ { "refId": "A", "expr": "sum by (model) (rate(ai_tokens_total{service_name=\"factory-api\", direction=\"out\"}[5m])) * 60", "legendFormat": "{{model}} out" } ] 31 }, 32 { 33 "id": 3, 34 "type": "timeseries", 35 "title": "Tokens / min by direction + model", 36 "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, 37 "gridPos": { "h": 9, "w": 12, "x": 0, "y": 4 }, 38 "fieldConfig": { "defaults": { "unit": "short", "custom": { "drawStyle": "line", "fillOpacity": 10 } }, "overrides": [] }, 39 "options": { "legend": { "displayMode": "table", "placement": "right" } }, 40 "targets": [ { "refId": "A", "expr": "factory_api:ai_tokens:rate5m * 60", "legendFormat": "{{model}} {{direction}}" } ] 41 }, 42 { 43 "id": 4, 44 "type": "timeseries", 45 "title": "AI request p95 by model (10 m)", 46 "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, 47 "gridPos": { "h": 9, "w": 12, "x": 12, "y": 4 }, 48 "fieldConfig": { "defaults": { "unit": "s", "custom": { "drawStyle": "line" }, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 5 } ] } }, "overrides": [] }, 49 "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, 50 "targets": [ { "refId": "A", "expr": "factory_api:ai_request_duration_seconds:p95", "legendFormat": "{{model}}" } ] 51 }, 52 { 53 "id": 5, 54 "type": "timeseries", 55 "title": "AI request rate by model (5 m)", 56 "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, 57 "gridPos": { "h": 8, "w": 8, "x": 0, "y": 13 }, 58 "fieldConfig": { "defaults": { "unit": "reqps", "custom": { "drawStyle": "line" } }, "overrides": [] }, 59 "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, 60 "targets": [ { "refId": "A", "expr": "sum by (model) (rate(ai_request_duration_seconds_count{service_name=\"factory-api\"}[5m]))", "legendFormat": "{{model}}" } ] 61 }, 62 { 63 "id": 6, 64 "type": "timeseries", 65 "title": "AI request mean latency by model (5 m)", 66 "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, 67 "gridPos": { "h": 8, "w": 8, "x": 8, "y": 13 }, 68 "fieldConfig": { "defaults": { "unit": "s", "custom": { "drawStyle": "line" } }, "overrides": [] }, 69 "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, 70 "targets": [ { "refId": "A", "expr": "sum by (model) (rate(ai_request_duration_seconds_sum{service_name=\"factory-api\"}[5m])) / sum by (model) (rate(ai_request_duration_seconds_count{service_name=\"factory-api\"}[5m]))", "legendFormat": "{{model}}" } ] 71 }, 72 { 73 "id": 7, 74 "type": "timeseries", 75 "title": "AI errors by code (error_total, 5 m)", 76 "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, 77 "gridPos": { "h": 8, "w": 8, "x": 16, "y": 13 }, 78 "fieldConfig": { "defaults": { "unit": "ops", "custom": { "drawStyle": "bars" } }, "overrides": [] }, 79 "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, 80 "targets": [ { "refId": "A", "expr": "sum by (code) (rate(error_total{service_name=\"factory-api\", code=~\"AI.*\"}[5m]))", "legendFormat": "{{code}}" } ] 81 } 82 ], 83 "annotations": { 84 "list": [ 85 { 86 "builtIn": 1, 87 "datasource": { "type": "grafana", "uid": "-- Grafana --" }, 88 "name": "Budget gauge — SPEC GAP", 89 "description": "The spec's AI dashboard asks for a 'budget-approaching gauge from the usage rollup'. The ai:usage-rollup repeatable job writes budget usage to the DB (readable via the API) but exports NO Prometheus gauge — and budget is not in the spec's 14-metric list. Recorded in infrastructure/observability/README.md (spec-conflict, AGENTS rule 29); the token-rate panels above are the live proxy for budget burn.", 90 "enable": true, 91 "hide": false, 92 "iconColor": "rgba(255, 96, 96, 1)" 93 } 94 ] 95 } 96} 97