Analytics — data flow & API testing guide

How the admin Analytics page gets its data, the exact endpoints behind it, and copy-pasteable curl examples to test them. For internal testing.

Source: Scicom-AI-Enterprise-Organization/GPUPlatform @ main · page: web/src/app/(app)/admin/analytics/

Two hosts — don't mix them up

The platform runs on two separate prod hostnames. The Analytics page itself is a web UI page; the data behind it comes from the gateway API.

Web UI browser

The Analytics page

https://serverless.aies.scicom.dev/admin/analytics

Open this in a browser to see the page. Admin-only — any non-admin login is redirected to /serverless, so your account needs the admin role.

Gateway API curl / clients

Where the data comes from

https://serverlessgpu.aies.scicom.dev

Serves all the /v1/... and /admin/... endpoints. Auth with an sgpu_… API key as a Bearer token. Also admin-scoped.

This trips people up: serverless.aies.scicom.dev = the web UI, serverlessgpu.aies.scicom.dev = the gateway API (note the extra gpu). Point curl / any OpenAI-style client at the gateway.

How the page gets its data

The page (page.tsx, admin-gated) renders a client component (analytics-view.tsx). On load it fires 4 parallel fetches to local Next.js API routes (/api/analytics/*). Those routes are server-side proxies: they inject auth and fan out to the real backends, so the browser never sees the gateway token or the SlurmUI secret.

browser (Analytics page)
  └─▶ /api/analytics/{gpuplatform,slurm,aliases,worker-events}  # Next.js proxy routes (forward your session cookie)
       ├─▶ gateway /v1/history/{kind} · /v1/history/summary · /admin/worker-events · /v1/global-env
       └─▶ SlurmUI /api/reports  # via a server-only aura_… admin token

Two data planes are kept deliberately separate: GPU Platform history (carries $ cost = cost_per_hr × duration) and SlurmUI reports (no cost — contributes job counts + GPU-hours).

The proxy routes (what the page calls)

Proxy routeProxies toPurpose
GET /api/analytics/gpuplatformgateway /v1/history/{kind} + /summaryGPU Platform usage & spend (the main data)
GET /api/analytics/slurmSlurmUI /api/reportsSlurm jobs + GPU-hours + per-day history
GET /api/analytics/aliases · PUTgateway /v1/global-envGPU-source → label alias map
GET /api/analytics/worker-eventsgateway /admin/worker-eventsWorker on/off lifecycle (GPU Timeline tab)

The gateway endpoints (the real data source)

These are what you test directly with curl. All are admin-scoped admin only — a non-admin key gets 403 and an empty result. Base URL = https://serverlessgpu.aies.scicom.dev.

EndpointQuery paramsReturns
GET /v1/historylist of available history kinds
GET /v1/history/benchmarkssince, until (ISO),
order=desc, limit≤1000, offset
{ jobs: [...], has_more: bool }
page through with offset until has_more=false
GET /v1/history/training
GET /v1/history/compute
GET /v1/history/inference
GET /v1/history/endpoints
GET /v1/history/summarysince, until, tz{ rows: [...] } — exact per-day inference counts/tokens used by the charts
GET /admin/worker-eventssince, until, limit{ count, events: [...] } — durable worker lifecycle events
GET /v1/global-env[{ key, value }] — alias map lives under ANALYTICS_SOURCE_ALIASES

Example curls

1 · Set up

# gateway host + an ADMIN sgpu API key (create one in the web UI → Settings → API keys)
export GW=https://serverlessgpu.aies.scicom.dev
export TOKEN=sgpu_your_admin_api_key_here

# the window you want to query — ISO 8601, UTC
export SINCE=2026-06-01T00:00:00.000Z
export UNTIL=2026-06-15T23:59:59.000Z

# sanity check: list the available history kinds
curl -s "$GW/v1/history" -H "Authorization: Bearer $TOKEN" | jq

2 · Job history per kind (benchmark / training / compute / inference / endpoints)

# newest-first, max 1000 per page; bump offset to page through
curl -s "$GW/v1/history/benchmarks?since=$SINCE&until=$UNTIL&order=desc&limit=1000&offset=0" \
  -H "Authorization: Bearer $TOKEN" | jq '{count: (.jobs|length), has_more}'

# same shape for the other kinds
for kind in training compute inference endpoints; do
  echo "== $kind =="
  curl -s "$GW/v1/history/$kind?since=$SINCE&until=$UNTIL&order=desc&limit=1000" \
    -H "Authorization: Bearer $TOKEN" | jq '{count: (.jobs|length), has_more}'
done

3 · Inference summary (the chart numbers)

# exact per-day counts/tokens — tz controls day bucketing
curl -s "$GW/v1/history/summary?since=$SINCE&until=$UNTIL&tz=Asia/Kuala_Lumpur" \
  -H "Authorization: Bearer $TOKEN" | jq '.rows[:3]'

4 · Worker lifecycle events (GPU Timeline tab)

curl -s "$GW/admin/worker-events?since=$SINCE&until=$UNTIL&limit=20000" \
  -H "Authorization: Bearer $TOKEN" | jq '{count, sample: .events[:2]}'

5 · Source alias map

curl -s "$GW/v1/global-env" -H "Authorization: Bearer $TOKEN" \
  | jq '.[] | select(.key=="ANALYTICS_SOURCE_ALIASES")'
SlurmUI data is not directly testable by you. The /api/analytics/slurm proxy authenticates to SlurmUI with a server-only aura_… admin token that the browser never sees. You can only reach Slurm numbers through the web page (logged in as admin), not via the gateway.

Notes & gotchas

Internal testing reference · GPU Platform analytics · generated from main.