From 26a6c2f35de2425aa3fe4e322d7fae537cd499b6 Mon Sep 17 00:00:00 2001 From: Jonathan Mohrbacher Date: Tue, 1 Dec 2026 21:30:25 -0500 Subject: [PATCH] [NO-JIRA] Add daily spend by machine panel and remove Codex mentions from llm-spend --- .../grafana-dashboards/llm-spend.json | 166 +++++++++++++----- 1 file changed, 119 insertions(+), 47 deletions(-) diff --git a/hosts/cloudbox/grafana-dashboards/llm-spend.json b/hosts/cloudbox/grafana-dashboards/llm-spend.json index e5426303..a064bebc 100644 --- a/hosts/cloudbox/grafana-dashboards/llm-spend.json +++ b/hosts/cloudbox/grafana-dashboards/llm-spend.json @@ -47,21 +47,6 @@ } ] }, - { - "matcher": { - "id": "byName", - "options": "Codex $ (notional)" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "purple", - "mode": "fixed" - } - } - ] - }, { "matcher": { "id": "byName", @@ -168,9 +153,9 @@ "type": "frser-sqlite-datasource", "uid": "llm-ledger" }, - "queryText": "SELECT\n SUM(CASE WHEN h.backend = 'max' THEN h.cost_usd ELSE 0 END) AS \"Max $ (notional)\",\n SUM(CASE WHEN h.backend = 'codex' THEN h.cost_usd ELSE 0 END) AS \"Codex $ (notional)\",\n SUM(CASE WHEN h.backend NOT IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS \"Cash $\",\n SUM(CASE WHEN b.bucket = 'gcp-commitment' THEN h.cost_usd ELSE 0 END) AS \"GCP commitment $\",\n SUM(CASE WHEN h.model LIKE '%gemini-4-neon%' THEN h.cost_usd ELSE 0 END) AS \"of which Neon $\",\n SUM(CASE WHEN b.bucket = 'claude-vertex' THEN h.cost_usd ELSE 0 END) AS \"Claude Vertex $\",\n SUM(h.n) AS requests\nFROM fleet_program_hourly h\nLEFT JOIN backend_bucket b ON b.backend = h.backend\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})", + "queryText": "SELECT\n SUM(CASE WHEN h.backend IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS \"Max $ (notional)\",\n SUM(CASE WHEN h.backend NOT IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS \"Cash $\",\n SUM(CASE WHEN b.bucket = 'gcp-commitment' THEN h.cost_usd ELSE 0 END) AS \"GCP commitment $\",\n SUM(CASE WHEN h.model LIKE '%gemini-4-neon%' THEN h.cost_usd ELSE 0 END) AS \"of which Neon $\",\n SUM(CASE WHEN b.bucket = 'claude-vertex' THEN h.cost_usd ELSE 0 END) AS \"Claude Vertex $\",\n SUM(h.n) AS requests\nFROM fleet_program_hourly h\nLEFT JOIN backend_bucket b ON b.backend = h.backend\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})", "queryType": "table", - "rawQueryText": "SELECT\n SUM(CASE WHEN h.backend = 'max' THEN h.cost_usd ELSE 0 END) AS \"Max $ (notional)\",\n SUM(CASE WHEN h.backend = 'codex' THEN h.cost_usd ELSE 0 END) AS \"Codex $ (notional)\",\n SUM(CASE WHEN h.backend NOT IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS \"Cash $\",\n SUM(CASE WHEN b.bucket = 'gcp-commitment' THEN h.cost_usd ELSE 0 END) AS \"GCP commitment $\",\n SUM(CASE WHEN h.model LIKE '%gemini-4-neon%' THEN h.cost_usd ELSE 0 END) AS \"of which Neon $\",\n SUM(CASE WHEN b.bucket = 'claude-vertex' THEN h.cost_usd ELSE 0 END) AS \"Claude Vertex $\",\n SUM(h.n) AS requests\nFROM fleet_program_hourly h\nLEFT JOIN backend_bucket b ON b.backend = h.backend\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})", + "rawQueryText": "SELECT\n SUM(CASE WHEN h.backend IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS \"Max $ (notional)\",\n SUM(CASE WHEN h.backend NOT IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS \"Cash $\",\n SUM(CASE WHEN b.bucket = 'gcp-commitment' THEN h.cost_usd ELSE 0 END) AS \"GCP commitment $\",\n SUM(CASE WHEN h.model LIKE '%gemini-4-neon%' THEN h.cost_usd ELSE 0 END) AS \"of which Neon $\",\n SUM(CASE WHEN b.bucket = 'claude-vertex' THEN h.cost_usd ELSE 0 END) AS \"Claude Vertex $\",\n SUM(h.n) AS requests\nFROM fleet_program_hourly h\nLEFT JOIN backend_bucket b ON b.backend = h.backend\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})", "refId": "A", "timeColumns": [] } @@ -178,6 +163,109 @@ "title": "Overview & Billing Buckets (selected range)", "type": "stat" }, + { + "datasource": { + "type": "frser-sqlite-datasource", + "uid": "llm-ledger" + }, + "description": "Total daily spend per machine, stacked by host (cloudbox, devbox, mac). Price basis: combined total \u2014 Max is notional list-price USD (not billed), while Vertex / agy / enterprise are cash / commitment USD; filter by Backend to view either alone. Day boundary: EST (UTC-5, matching session-tags ET reports in winter; 1h shift in EDT). First and last bars may be partial if the selected range starts or ends mid-day.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic-by-name" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "$/day", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "currencyUSD" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 13, + "options": { + "barRadius": 0, + "barWidth": 0.85, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "orientation": "vertical", + "showValue": "auto", + "stacking": "normal", + "tooltip": { + "mode": "multi", + "sort": "desc" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "pluginVersion": "13.0.13", + "targets": [ + { + "datasource": { + "type": "frser-sqlite-datasource", + "uid": "llm-ledger" + }, + "queryText": "SELECT\n strftime('%Y-%m-%d', (h.hour - 18000000) / 1000, 'unixepoch') AS day,\n h.host AS host,\n ROUND(SUM(h.cost_usd), 2) AS spend\nFROM fleet_program_hourly h\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})\nGROUP BY 1, 2\nORDER BY 1, 2", + "queryType": "table", + "rawQueryText": "SELECT\n strftime('%Y-%m-%d', (h.hour - 18000000) / 1000, 'unixepoch') AS day,\n h.host AS host,\n ROUND(SUM(h.cost_usd), 2) AS spend\nFROM fleet_program_hourly h\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})\nGROUP BY 1, 2\nORDER BY 1, 2", + "refId": "A", + "timeColumns": [] + } + ], + "title": "Daily spend by machine (EST / UTC-5 days \u2014 notional + cash)", + "transformations": [ + { + "id": "groupingToMatrix", + "options": { + "columnField": "host", + "emptyValue": "zero", + "rowField": "day", + "valueField": "spend" + } + } + ], + "type": "barchart" + }, { "datasource": { "type": "frser-sqlite-datasource", @@ -208,7 +296,7 @@ "h": 8, "w": 12, "x": 0, - "y": 5 + "y": 13 }, "id": 2, "interval": "1h", @@ -273,7 +361,7 @@ "h": 8, "w": 12, "x": 12, - "y": 5 + "y": 13 }, "id": 3, "interval": "1h", @@ -305,7 +393,7 @@ ] } ], - "title": "Max / Codex notional (${rate:text}) per program", + "title": "Max notional (${rate:text}) per program", "type": "timeseries" }, { @@ -338,7 +426,7 @@ "h": 8, "w": 12, "x": 0, - "y": 13 + "y": 21 }, "id": 11, "interval": "1h", @@ -403,7 +491,7 @@ "h": 8, "w": 12, "x": 12, - "y": 13 + "y": 21 }, "id": 12, "interval": "1h", @@ -468,7 +556,7 @@ "h": 8, "w": 12, "x": 0, - "y": 21 + "y": 29 }, "id": 8, "interval": "1h", @@ -545,7 +633,7 @@ "h": 8, "w": 12, "x": 12, - "y": 21 + "y": 29 }, "id": 9, "options": { @@ -654,22 +742,6 @@ } ] }, - { - "matcher": { - "id": "byName", - "options": "codex_usd" - }, - "properties": [ - { - "id": "unit", - "value": "currencyUSD" - }, - { - "id": "displayName", - "value": "Codex $ (notional)" - } - ] - }, { "matcher": { "id": "byName", @@ -708,7 +780,7 @@ "h": 9, "w": 24, "x": 0, - "y": 29 + "y": 37 }, "id": 4, "options": { @@ -729,14 +801,14 @@ "type": "frser-sqlite-datasource", "uid": "llm-ledger" }, - "queryText": "SELECT\n h.program AS program,\n SUM(CASE WHEN h.backend = 'max' THEN h.cost_usd ELSE 0 END) AS max_usd,\n SUM(CASE WHEN h.backend = 'codex' THEN h.cost_usd ELSE 0 END) AS codex_usd,\n SUM(CASE WHEN h.backend NOT IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS cash_usd,\n SUM(h.n) AS requests\nFROM fleet_program_hourly h\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})\nGROUP BY 1\nORDER BY (max_usd + codex_usd + cash_usd) DESC", + "queryText": "SELECT\n h.program AS program,\n SUM(CASE WHEN h.backend IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS max_usd,\n SUM(CASE WHEN h.backend NOT IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS cash_usd,\n SUM(h.n) AS requests\nFROM fleet_program_hourly h\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})\nGROUP BY 1\nORDER BY (max_usd + cash_usd) DESC", "queryType": "table", - "rawQueryText": "SELECT\n h.program AS program,\n SUM(CASE WHEN h.backend = 'max' THEN h.cost_usd ELSE 0 END) AS max_usd,\n SUM(CASE WHEN h.backend = 'codex' THEN h.cost_usd ELSE 0 END) AS codex_usd,\n SUM(CASE WHEN h.backend NOT IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS cash_usd,\n SUM(h.n) AS requests\nFROM fleet_program_hourly h\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})\nGROUP BY 1\nORDER BY (max_usd + codex_usd + cash_usd) DESC", + "rawQueryText": "SELECT\n h.program AS program,\n SUM(CASE WHEN h.backend IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS max_usd,\n SUM(CASE WHEN h.backend NOT IN ('max', 'codex') THEN h.cost_usd ELSE 0 END) AS cash_usd,\n SUM(h.n) AS requests\nFROM fleet_program_hourly h\nWHERE h.hour >= $__from AND h.hour < $__to\n AND h.host IN (${host:sqlstring})\n AND h.backend IN (${backend:sqlstring})\n AND h.model IN (${model:sqlstring})\n AND h.program IN (${program:sqlstring})\nGROUP BY 1\nORDER BY (max_usd + cash_usd) DESC", "refId": "A", "timeColumns": [] } ], - "title": "Program Breakdown: Max / Codex $ (notional) & cash $ (Vertex/agy/enterprise)", + "title": "Program Breakdown: Max $ (notional) & cash $ (Vertex/agy/enterprise)", "type": "table" }, { @@ -890,7 +962,7 @@ "h": 9, "w": 24, "x": 0, - "y": 38 + "y": 46 }, "id": 6, "options": { @@ -918,7 +990,7 @@ "timeColumns": [] } ], - "title": "Model Breakdown: Max / Codex $ (notional) & cash $ (Vertex/agy/enterprise)", + "title": "Model Breakdown: Max $ (notional) & cash $ (Vertex/agy/enterprise)", "type": "table" }, { @@ -1077,7 +1149,7 @@ "h": 10, "w": 24, "x": 0, - "y": 47 + "y": 55 }, "id": 7, "options": {