Request flows
Ingest (agent → API → TSDB)
- The agent opens an mTLS conn to :8443
- The server TLS config verifies the peer cert against the issued CA
agentIDFromCert(r)→ identity (NEVER from the body/header)- SELECT organization_id, status, region_id FROM agents
- Sample[]: organization_id + agent_id + host are attached to every metric
router.VMForRegion(region_id)→ the region's TSDB clientvm.Write(samples)- UPDATE agents SET last_seen_at = now()
Cabinet query
- Browser →
/api/v1/orgs/:slug/query/range?metric=X&host=Y - Session middleware (cookie) → userCtx
- orgMiddleware → orgContext{OrgID, UserID, Role}
composeQuery("X", {organization_id: OrgID, host: Y})vm.Range(promQuery, start, end, step)
Embed query
- Partner backend: POST /api/v1/embed/tokens with mk_xxx
- The API verifies the key origin against the allowlist
- A JWT is issued: claims contain {org_id, filters}
- The partner puts the JWT in an iframe or postMessage
- SDK →
/api/v1/embed/query/rangewith a Bearer JWT - embed.Required: parses the JWT, extracts filters from claims
- composeQuery with claim.filters