# Session 6.6 — Items 5 & 6: System Health + Spend Column ## Files | File | Action | What | |------|--------|------| | `src/lib/litellm.ts` | REPLACE | Added `listTeams()`, `getLitellmHealth()`, `getGlobalSpend()`, `getPerTeamSpend()` | | `src/app/api/admin/health/route.ts` | **NEW** | Returns tenant phase counts, aggregate + per-tenant spend, vLLM & LiteLLM health | | `src/components/admin/admin-panel.tsx` | REPLACE | Added "Health" tab (service indicators, tenant overview, spend cards) + "Spend (CHF)" column in tenants table | | `patch-i18n-admin-health.mjs` | **RUN ONCE** | Patches all 4 i18n files with new admin keys | ## Steps 1. Drop in the 3 source files (overwrite existing) 2. Run the i18n patcher from the portal root: ```bash node patch-i18n-admin-health.mjs ``` 3. Build and deploy ## Environment Variables (optional) - `VLLM_HEALTH_URL` — defaults to `http://vllm.inference.svc:8000`. Set if your vLLM is elsewhere. - `LITELLM_INTERNAL_URL` / `LITELLM_MASTER_KEY` — already configured. ## Notes - The health API uses `Promise.allSettled` so a single service being down won't break the whole page. - Per-tenant spend is fetched from LiteLLM's `/team/list` which returns the cumulative `spend` per team. This is mapped to tenant names via `status.litellmTeamId` on the PiecedTenant CR. - The spend column in the tenants table piggybacks on the same health data — fetched once when switching to the tenants tab. - If LiteLLM's `/team/list` or `/global/spend` response format differs from what I assumed, you may need to adjust the parsing in `litellm.ts`. The functions have fallbacks for common response shapes.