MAQPNADocs

maqpna usage buckets

Print hourly usage buckets per tenant

Observe-o json | yaml

Synopsis#

maqpna usage buckets [--from 24h|RFC3339] [--to RFC3339] [--tenant T] [--ledger FILE | --gateway URL]
                     [--no-sessions] [--format table|csv] [-o json]

Description#

From the help of maqpna usage:

Sandbox seconds come from AgentSessions (status.readyAt to status.outcome.finishedAt, or now while running; sessions that never became ready are not billed). Calls, tokens and approval requests come from the audit ledger (--ledger FILE offline, or the gateway's /v1/audit/records). Namespaces map to tenants through Tenant.spec.namespaces; usage outside any tenant has an empty tenant. Buckets carry counts only.

Finished sessions' sandbox time is also recorded by the gateway in the ledger (usageReporting, decision "usage"), so it survives AgentSession garbage collection; sessions found in the ledger are not counted twice.

Flags#

FlagTypeDescriptionDefault
--formatstringtable | csv (ignored with -o json|yaml)table
--fromstringstart: a duration ago (24h) or an RFC3339 time24h
--gatewaystringgateway base URL (env MAQPNA_GATEWAY_URL; default: the context's gateway)none
--ledgerstringread the audit ledger from FILE instead of the gatewaynone
--no-sessionsswitchskip AgentSessions (calls, tokens and approvals only; no cluster access)none
--oidc-token-filestringfile holding an OIDC access token for the admin API (env MAQPNA_OIDC_TOKEN_FILE); wins over --tokennone
--tenantstringonly this tenantnone
--tostringend (RFC3339; default now)none
--tokenstringstatic admin token (env MAQPNA_ADMIN_TOKEN; dev/break-glass)none

The global flags (--context, -o, --no-color, ...) work with every command.

Examples#

maqpna usage buckets --from 24h --gateway "$GW"

What happens when you run it#

  • Talks to the gateway: --gateway, else MAQPNA_GATEWAY_URL, else the current context's gateway (maqpna context).
  • Authenticates to the admin API with the token stored by maqpna login, --oidc-token-file, or a static --token (MAQPNA_ADMIN_TOKEN).
  • Reads the audit ledger offline with --ledger FILE: read the audit ledger from FILE instead of the gateway.
  • Prints a table by default; -o json or -o yaml print the data, and --jq EXPR filters the JSON.

Exit codes#

CodeMeaning
0success
1error (the message says what failed, with a hint when there is one)
2usage error: unknown flag, missing argument or bad value; the synopsis is printed
3a check failed, a change is blocked, or a result did not match (tamper, policy mismatch) (not used by this command)

Terminal demo#

maqpna usage buckets.cast