{ "uid": "factory-ai", "title": "Factory — AI", "tags": ["factory", "observability", "ai"], "timezone": "browser", "schemaVersion": 39, "version": 1, "editable": true, "refresh": "30s", "time": { "from": "now-6h", "to": "now" }, "panels": [ { "id": 1, "type": "stat", "title": "Tokens / min (in, 5 m)", "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, "gridPos": { "h": 4, "w": 6, "x": 0, "y": 0 }, "fieldConfig": { "defaults": { "unit": "short", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [] }, "options": { "colorMode": "value", "graphMode": "area" }, "targets": [ { "refId": "A", "expr": "sum by (model) (rate(ai_tokens_total{service_name=\"factory-api\", direction=\"in\"}[5m])) * 60", "legendFormat": "{{model}} in" } ] }, { "id": 2, "type": "stat", "title": "Tokens / min (out, 5 m)", "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, "gridPos": { "h": 4, "w": 6, "x": 6, "y": 0 }, "fieldConfig": { "defaults": { "unit": "short", "thresholds": { "mode": "absolute", "steps": [ { "color": "blue", "value": null } ] } }, "overrides": [] }, "options": { "colorMode": "value", "graphMode": "area" }, "targets": [ { "refId": "A", "expr": "sum by (model) (rate(ai_tokens_total{service_name=\"factory-api\", direction=\"out\"}[5m])) * 60", "legendFormat": "{{model}} out" } ] }, { "id": 3, "type": "timeseries", "title": "Tokens / min by direction + model", "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, "gridPos": { "h": 9, "w": 12, "x": 0, "y": 4 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "drawStyle": "line", "fillOpacity": 10 } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "right" } }, "targets": [ { "refId": "A", "expr": "factory_api:ai_tokens:rate5m * 60", "legendFormat": "{{model}} {{direction}}" } ] }, { "id": 4, "type": "timeseries", "title": "AI request p95 by model (10 m)", "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, "gridPos": { "h": 9, "w": 12, "x": 12, "y": 4 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "drawStyle": "line" }, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 5 } ] } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, "targets": [ { "refId": "A", "expr": "factory_api:ai_request_duration_seconds:p95", "legendFormat": "{{model}}" } ] }, { "id": 5, "type": "timeseries", "title": "AI request rate by model (5 m)", "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, "gridPos": { "h": 8, "w": 8, "x": 0, "y": 13 }, "fieldConfig": { "defaults": { "unit": "reqps", "custom": { "drawStyle": "line" } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, "targets": [ { "refId": "A", "expr": "sum by (model) (rate(ai_request_duration_seconds_count{service_name=\"factory-api\"}[5m]))", "legendFormat": "{{model}}" } ] }, { "id": 6, "type": "timeseries", "title": "AI request mean latency by model (5 m)", "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, "gridPos": { "h": 8, "w": 8, "x": 8, "y": 13 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "drawStyle": "line" } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, "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}}" } ] }, { "id": 7, "type": "timeseries", "title": "AI errors by code (error_total, 5 m)", "datasource": { "type": "prometheus", "uid": "factory-prometheus" }, "gridPos": { "h": 8, "w": 8, "x": 16, "y": 13 }, "fieldConfig": { "defaults": { "unit": "ops", "custom": { "drawStyle": "bars" } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, "targets": [ { "refId": "A", "expr": "sum by (code) (rate(error_total{service_name=\"factory-api\", code=~\"AI.*\"}[5m]))", "legendFormat": "{{code}}" } ] } ], "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "name": "Budget gauge — SPEC GAP", "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.", "enable": true, "hide": false, "iconColor": "rgba(255, 96, 96, 1)" } ] } }