Request logging
The request log table in the admin UI, showing per-request identity, routing, status, and cost fields.
The Request logs page is in Organisation › Governance & security (/org/<id>/governance/request-logs, the request-logs permission REQUEST_LOGS_VIEW). It shows the logs of the organisation in the address; a platform administrator switches the organisation in the context bar (there is no cross-organisation filter). The former address /logs redirects to your own organisation's page.
Myra AI Workspace captures a structured log entry for every inference request. Each entry records the provider used, token counts, cost, latency, cache status, and — optionally — the full prompt and response text. View logs in real time in the admin UI under Request Logs, or query them via the API.
Logging happens after the response is sent. It adds no latency to the request path.
Log entry fields
The tables below group the main fields. The complete field set of the API — including trace_id, client_request_id, leg_kind, response_raw and prompt_scrubbed, and which fields only the list or only the single-entry response returns — is in the Logs API.
Identity
| Field | Type | Description |
|---|---|---|
id |
string | Unique request ID (UUID) |
ts |
unix seconds | Event timestamp. The request_log.ts column is stored in milliseconds; the API projects ROUND(ts / 1000), so the returned value is in seconds. |
tenant_id |
string | Tenant that owns this gateway |
gateway_id |
string | Gateway through which the request was routed |
Routing
| Field | Type | Description |
|---|---|---|
provider |
string | Provider that handled the request (e.g. openai, anthropic) |
model |
string | Model name as sent in the request |
fallback_provider |
string | null | Provider used if the primary provider failed |
fallback_model |
string | null | Model used on the fallback attempt |
upstream_attempts |
integer | Provider dials attempted for this turn. 1 = answered first try, >1 = retries/fallbacks were used, 0 = no provider was ever dialled (refused before dispatch). Failed dials are counted from a later release on; rows written before that release record 0 even when dials occurred. |
Status
| Field | Type | Description |
|---|---|---|
status |
integer | HTTP status code returned to the caller |
aborted |
integer | 1 if the client cancelled the request mid-generation (e.g. pressing Stop) or disconnected while a tool loop was still running (the loop then stops dialling further provider calls), 0 otherwise. Its purpose is to separate a cancel from a genuine empty completion among status 200 rows: a post-header stream cancel is status 200 with zero token counts (the provider never returned a usage block) and aborted 1, whereas a real empty answer is status 200, output_tokens 0, aborted 0. A cancel detected before the response was streamed lands as status 499, and may also carry aborted 1 (a buffered-collect cancel sets both); those 499 rows are already counted by the client_aborted stats metric, so the empty-vs-cancel distinction only needs aborted on the status 200 rows. Stored on the row and queryable via SQL/ClickHouse, but not returned by the logs API or shown in the log viewer (like saved_latency_ms and time_to_first_token_ms). |
blocked |
integer | 1 if the request was refused — by a guardrail detector or by one of the gateway's own rules (a budget, quota, trial or allowance limit, an inactive subscription, a rate limit, the IP allowlist, a model allowlist, a model disabled on the gateway, the PII gate, a sub-processor objection) — 0 otherwise |
blocked_by |
string | null | What refused the request: the detector's name for a guardrail block, otherwise the rule (for example quota, trial_budget, rate_limit, ip_allowlist, plan_model_allowlist, pii_protection_required) — the full list is in the blocked_by row of the SIEM event payload |
block_reason |
string | null | Human-readable block reason. Omitted when metadata_only is set. |
block_kind |
string | null | Why the request was blocked, also when metadata_only is set: unconfigured (a fail-closed guardrail that is not set up), unavailable (a fail-closed guardrail that could not run), policy (a guardrail blocked it) or null (not blocked, or blocked by a budget, rate limit or other rule). The log list shows the first two next to the detector's name. |
rate_limited |
integer | 1 if the request was rejected by a rate limit, 0 otherwise |
Cache
| Field | Type | Description |
|---|---|---|
cached |
integer | 1 if the response was served from cache, 0 otherwise |
saved_cost_usd |
number | null | Cost saved by serving from cache |
💡 Note:
saved_latency_msis stored on the request-log row but is not returned by the logs API — the projection omits it.
Tokens
| Field | Type | Description |
|---|---|---|
input_tokens |
integer | Prompt tokens consumed |
output_tokens |
integer | Completion tokens generated |
cache_creation_tokens |
integer | null | Tokens written to Anthropic prompt cache |
cache_read_tokens |
integer | null | Tokens read from Anthropic prompt cache |
cache_deletion_tokens |
integer | null | Tokens evicted from the Anthropic prompt cache |
Cost
| Field | Type | Description |
|---|---|---|
cost_usd |
number | null | Estimated cost in USD, computed from the prices table |
Timing
| Field | Type | Description |
|---|---|---|
latency_ms |
integer | Total request latency from gateway receipt to response sent |
upstream_latency_ms |
integer | null | Time spent waiting for the upstream provider |
💡 Note:
time_to_first_token_ms(time to first SSE token, streaming requests only) is stored on the request-log row but is not returned by the logs API — the projection omits it.
Payload
| Field | Type | Description |
|---|---|---|
prompt |
string | null | Full prompt text (null if log_payloads: false or suppressed per-request). Inline binary — base64 attachment bytes — is never stored: it is replaced by [binary omitted: N bytes], leaving the block type and media type visible. See the Logs API for the exact rule. |
response |
string | null | Full response text (null if payload logging is off). Returned only by the single-entry endpoint GET /logs/{id}; a list row carries response_raw instead. |
payload_expired |
boolean | true when the operator-run payload expiry deleted this entry's prompt and response; false otherwise, including when the content was never logged. See Content expired. |
payload_expired_at |
integer | null | Unix seconds at which the content was expired. null when payload_expired is false, and when the stored marker is unreadable. |
Detectors
| Field | Type | Description |
|---|---|---|
detectors_fired |
array of strings | Names of the detectors that fired for this request (empty array when none fired) |
scrub_applied |
integer | 1 if PII scrubbing (masking) was applied to this request, 0 otherwise |
Guardrail
| Field | Type | Description |
|---|---|---|
guardrail_verdict |
string | null | The guardrail pipeline verdict for this request. Omitted when metadata_only is set. |
guardrail_latency_ms |
integer | null | Time spent in the guardrail pipeline |
Privacy state (chat turns)
A turn sent from the web app also records which privacy mode the composer showed when you sent the message, next to what the gateway applied. The Logs page turns this into a badge on the row, so "I switched privacy off, but the answer was still masked" can be answered from the log alone. It is a record only: it never changes routing, masking or the answer.
| Badge | Meaning |
|---|---|
| shown: <mode> (neutral) | The mode shown in the app when the message was sent (protected, masked or public) agrees with what was applied. A turn answered from the cache or refused says so in the badge itself. |
| privacy differs (warning) | What the app showed differs from what was applied. Hover for the reason: a privacy mandate masked a request the app showed as public, or the request was routed differently from what the app showed. |
| privacy header invalid (neutral) | The app sent the privacy information in a format the gateway could not read. Only the fact that it was unusable is recorded, never the value. |
Shown versus applied: the app records the mode that was on screen at the moment you pressed send (and the last privacy control used since the previous message, for example a tap that was refused because an answer was still being written); the gateway records what it applied. These can legitimately differ. For the first message of a new chat on Auto, the shown mode is the one the home screen showed before you sent; if Auto then serves another mode, the row shows privacy differs. While the home screen still reads "Decided on send", no mode is shown, so that message carries no privacy badge. Voice-mode turns carry no privacy badge either.
- Masked is the route's configured posture: the gateway masks personal data before it leaves for an external provider. It says the route is set up to mask, not that something was replaced in this request. Whether anything was actually replaced is recorded separately by
scrub_appliedand the guardrail fields of the entry. - Cached: when the answer came from the cache nothing was sent to a provider, so the applied mode is not recorded; the badge shows only what the app showed and the
cacheoutcome. - Not sent: a request the gateway refused before it reached a provider records the
refusedoutcome and no applied mode.
Requests that carry no privacy information (API clients, background requests of the chat interface, older app versions) show no privacy badge. With payload logging off or metadata_only set, the badge still appears, because it contains no message content. A bulk export (metadata_only=1) carries the privacy state in meta.privacy_state as well.
Stream
| Field | Type | Description |
|---|---|---|
is_streaming |
integer | 1 if the response was streamed (SSE), 0 otherwise |
api_variant |
string | null | API surface the request used (for example the Chat Completions or Messages variant) |
Client
| Field | Type | Description |
|---|---|---|
client_ip |
string | null | Source IP of the caller |
user_agent |
string | null | User-Agent header of the request |
referer |
string | null | Referer header of the request |
request_size_bytes |
integer | null | Size of the request body in bytes |
Custom metadata
| Field | Type | Description |
|---|---|---|
meta |
object | The guardrail protection markers for this request — see Protection markers. Always carries at least guardrail_gap. Under metadata_only it carries the boolean markers but not guardrail_error. |
⚠️ What is stored and what is returned are not the same set. The
metacolumn onrequest_logholds thex-aig-meta-*key/value map from the request headers plus the gateway-owned diagnostic keys listed below. Themetafield returned byGET /logsandGET /logs/{id}is a curated subset: the guardrail protection markers only. The keys below are reachable by direct SQL (JSON_EXTRACT(meta, '$.<key>')), not through the API.
The aig* key space inside meta is reserved for the gateway: an x-aig-meta-aig…
request header is dropped, never stored, so these keys are always gateway-authored. A client
x-aig-meta-* header named spend_read_degraded or spend_unverified, named after a guardrail
protection marker, or named after a delegation-lineage key (delegate_depth, parent_request_id,
human_root) is dropped as well, so delegation lineage is always gateway-authored. (Header names
containing an underscore are not forwarded by the gateway's web server.)
stored meta key |
Meaning |
|---|---|
aig_stream_error |
A typed error was delivered as an SSE frame on an already-open stream (so the wire status was 200 while status records the real one, e.g. 403). |
aig_no_dispatch |
Invariant tripwire: a streaming turn ended having dispatched to no provider and recorded no reason. Always a gateway defect; report it to support. |
aig_mcp_policy_dropped |
MCP connector references were dropped because the project forbids external egress. |
aig_prompt_binary_stripped |
The number of inline-binary payloads (base64 attachment bytes) replaced by [binary omitted: N bytes] in this entry's prompt. Absent when nothing was replaced. Gateway-owned (aig_ prefix — a client x-aig-meta-* header cannot set it). See the Logs API. |
aig_payload_truncated |
The payload columns (prompt, response, response_raw, prompt_scrubbed) that were cut to fit the entry's 12 MiB payload budget, as an array of column names. Absent when nothing was cut. Gateway-owned. See the Logs API. |
threat_taxonomy |
Present only on a request with a classified threat signal — a guardrail / PII-gate verdict, a resource refusal (a rate limit or any budget, quota, trial-credit or managed-allowance refusal: LLM10 / AML.T0034), an egress-exfiltration match, or indirect prompt injection: the OWASP-LLM-Top-10 category ids and MITRE-ATLAS technique ids ({ "owasp": [...], "atlas": [...] }). See the compliance crosswalk. |
aig_meta_truncated |
The meta column exceeded its storage cap and was truncated: some keys were dropped. Also returned by the API as a protection marker — and it counts as a guardrail gap, because every other marker on such a row is unknown rather than false, and guardrail_gap: false is a positive statement that the request was protected. |
spend_unverified |
A money gate refused the request (503 spend_unverified, retryable) because the spend it guards could not be read — the Myra-provided-model spend check, or the workspace wallet's balance. The value names the scope that could not be read: user, tenant, pool, fleet (a paid self-serve workspace's delegated sub-agent run on a Myra-hosted model), price, or wallet (the workspace wallet balance — any plan, on /v1 and the conversation summarize route). A partner-billed tenant refused at /v1 admission because a spend read failed carries the scope of that read: token, tenant, gateway, user or team (see Partner-billed tenants). An outage marker, not a policy block: blocked_by is not set. See Budgets. |
spend_read_degraded |
A budget scope's spend could not be read (database failure). The budget hard stop then failed open for THAT scope (request allowed; that scope's cap was not enforced for it — the turn is still metered at turn end, so an outage can leave spend under-counted, never over-counted) and the soft alert was skipped — see Budgets. The flag marks the failed read, not the outcome: a tenant that fails closed (spend_fail_closed, or a partner-billed tenant) carries it on the refused request too. |
Querying request logs
Proceed as follows to query request logs via the API:
-
Send a
GETrequest to/admin/v1/logswith an admin token.- The endpoint accepts the following query parameters:
Parameter Description limitNumber of entries to return (default: 50, maximum 200) offsetPagination offset tenant_idFilter by tenant gateway_idFilter by gateway providerFilter by provider name modelFilter by model name statusFilter by HTTP status code blockedSet to 1to return only blocked requeststrace_idReturn only the request with this trace id (a UUID; anything else is 400)guardrail_outcomeFilter by guardrail outcome: blocked,scrubbed,flagged,degraded,compliance, orany. A request where a guardrail block withheld a tool result in the agent's tool loop without refusing the request (shown with the result withheld badge) is notscrubbedorflagged;blockedselects refused requests only, so find it withany.degradedselects the requests that reached a provider without the protection they were configured to get;complianceselects only the incidents where unmasked personal data actually left the estate;anymatches either kind.sinceStart of the time range, as a numeric Unix timestamp in milliseconds. Only entries with ts >= sinceare returned. Whenguardrail_outcome=degradedand nosinceis given, it defaults to 30 days ago — that filter reads themetamarkers, which no index can serve. An explicitsinceis always honoured, and the console pre-fills the From date so the window is visible.untilEnd of the time range, as a numeric Unix timestamp in milliseconds. Use with sincefor a date range.metadata_onlySet to 1to omit the content columns from each entry (the prompt and the response among them) for a bulk export. Themetaprotection markers stay — seemetadata_onlyin the API reference for the exact set of withheld fields. -
If filtering blocked requests, add
blocked=1to the query string. - If filtering by time range, add the
sinceanduntilparameters as Unix timestamps in milliseconds.- The API returns a paginated list of log entries matching the filter.
⭐ Example:
# Last 10 blocked requests curl "https://gateway.example.com/admin/v1/logs?blocked=1&limit=10" \ -H "Cookie: aig_admin=<SESSION>" # Requests for a specific gateway since a given time (Unix ms) curl "https://gateway.example.com/admin/v1/logs?gateway_id={id}&since=1735732800000" \ -H "Cookie: aig_admin=<SESSION>"
-> The API returns a paginated list of log entries matching the specified filters.
Exporting from the console
The Request logs page's Export CSV / Export XLSX buttons download the currently
filtered entries (the Since/Until window, and every other active filter) as a
request-logs-<date>.csv / .xlsx file. The export is metadata only — it is fetched with
metadata_only=1, so no prompt, response, or other message content ever appears in it — and is
capped at 20,000 rows (the page says so when the cap cut an export short). The columns, in order:
ID, Timestamp (UTC) (ISO 8601), Tenant, Gateway, Provider, Model, Status,
Blocked, Blocked By, Input Tokens, Output Tokens, Cost (USD), Latency (ms),
Upstream Latency (ms), Guardrail Latency (ms), Scrubbed, Detectors (|-separated
detector names), Protection Gap (1 when the request reached a provider without the
protection it was configured to get, else 0 — the guardrail_gap marker), Gap Severity
(compliance or degraded when there is a gap, otherwise empty — the guardrail_gap_severity
marker), Rate Limited, Trace ID, Client Request ID (the caller's own X-Request-Id, when it sent a conforming one — see the Logs API; empty otherwise).
The two protection columns are the markers an auditor filters the page by (Guardrail outcome → degraded / compliance); without them an export selected by those filters would say nothing about why its rows were selected. They are booleans and an enum — the failing detector's name stays server-side.
Opening request content
The log table never shows prompts and answers inline. Clicking an entry that has stored content
opens the Open request content dialog. It asks Why do you need to see this? and notes that
this is logged with your name and reason, and shown in the audit log. Show content stays
disabled until you enter a reason (at most 500 bytes). The reason is recorded as a
request_log.content_read audit row before anything is shown (see the
Logs API). Cancel closes the dialog without reading
anything.
Opening one request
The page can be opened on one request: /org/<id>/governance/request-logs?request=<request id>
(the request's trace id, a UUID). A workflow run that a guardrail blocked links here from its
Open guardrail event link (see Workflows). The page then lists only
that request, says Showing one request: <id>, and — when the request has stored content —
opens the Open request content dialog for it straight away (the same reason rule as a click).
The other filters, the entry count and the export all apply to that one request. Show all
requests removes it and returns to the full list.
A value that is not a request id is never sent to the server (the export buttons are disabled too), and a request id that is not in this organisation's logs (unknown, another organisation's, or outside the other filters) lists nothing: both say This request is not in this organisation's request logs, or the current filters hide it.
Content expired
A log entry is in exactly one of three states:
| State | prompt / response |
payload_expired |
|---|---|---|
| Content logged | present | false |
Never logged (log_payloads: false, or suppressed per request) |
null |
false |
| Content expired (deleted by the operator-run payload expiry) | null |
true, with payload_expired_at |
The payload expiry is an operator-run script (scripts/request_log_payload_retention.sh; default 14 days, --days of 8 or more) and is not scheduled: it deletes the prompt and response text of entries older than the chosen number of days, when an operator runs it. Until it has run, older text stays readable. The optional ClickHouse copy expires its own text independently, after 14 days.
The log browser shows a Content expired badge on expired entries and nothing on never-logged ones, so an empty prompt is no longer ambiguous. Expiry removes only the prompt and response text: usage, cost, status, latency and the other metadata of the entry stay. The same flag is reported by the request-detail, guardrail-event and report views and, for the agent run's owner, as result_expired on the run result (see Read one agent run).
Enabling payload logging
Payload logging is controlled at two levels: per-gateway and per-request.
Disabling payload logging at gateway level
Proceed as follows to disable payload storage for all requests through a gateway:
-
Send a
PATCHrequest to/admin/v1/gateways/{id}with thelog_payloadsfield set tofalse.curl -X PATCH "https://gateway.example.com/admin/v1/gateways/{id}" \ -H "Cookie: aig_admin=<SESSION>" \ -H "Content-Type: application/json" \ -d '{"config": {"log_payloads": false}}'- The
promptandresponsefields are set tonullfor every subsequent request through that gateway.
- The
-> The gateway no longer stores prompt or response text in log entries.
Suppressing payloads per request
Proceed as follows to suppress payload logging for individual requests:
-
Include the
x-aig-collect-log-payloadheader set tofalsein the client request.# Log metadata but not the prompt/response text curl -s -X POST "https://gateway.example.com/v1/myapp/prod/openai/chat/completions" \ -H "x-aig-collect-log-payload: false" \ ...- The log entry is written with metadata only;
promptandresponseare set tonull.
- The log entry is written with metadata only;
-
If you want to skip the log entry entirely, include
x-aig-collect-log: falseinstead.# Skip logging entirely curl -s -X POST "https://gateway.example.com/v1/myapp/prod/openai/chat/completions" \ -H "x-aig-collect-log: false" \ ...- No log entry is written for this request.
-> The specified request is either logged without payload text, or not logged at all.
⚠️ Caution:
x-aig-collect-log-payload: falseonly suppresses payloads for the single request that includes the header. It does not change the gateway-levellog_payloadssetting. The header also strips the content fields of trace steps for that request (metadata such as lengths and counts is kept).
Attaching custom metadata
Any request header prefixed with x-aig-meta- is captured in the meta column of the log entry:
curl -s -X POST "https://gateway.example.com/v1/myapp/prod/openai/chat/completions" \
-H "x-aig-meta-session-id: sess_abc123" \
-H "x-aig-meta-feature-flag: new-summariser" \
...
The stored meta column will contain:
⚠️ Read it back with SQL, not with the logs API. The
metafield returned byGET /logsandGET /logs/{id}carries the guardrail protection markers only, not these client-supplied keys — see Custom metadata above. Query them withSELECT JSON_EXTRACT(meta, '$."session-id"') FROM request_log ….
Client metadata is bounded at the trust boundary: at most 16 keys per request (a deterministic
lexicographic subset when more are sent), each key at most 64 characters (longer keys are
dropped), and each value a single string truncated to 256 characters (the first value if a
header repeats). See the x-aig-meta-* caps
for the full accepted shape. These caps guarantee the meta object can never overflow its storage
column, so an over-sized or malformed metadata set never causes the log row to be lost.
Disabling request logging for a tenant
Request logging can be switched off for a whole tenant. When it is off, the gateway stores no request-log entries for the traffic of that tenant, and the Request Logs view stays empty for it. Billing and quotas are not affected — they do not depend on the request log.
The setting is Disable request logging for this tenant on the tenant settings, and it is restricted to platform administrators. A tenant admin cannot switch off the logging of its own tenant, so a tenant cannot disable its own compliance logging.
When the organisation in view has its logging off, the Request logs page shows the banner Request logging is disabled for tenant "<slug>". No new request log entries are being stored for its traffic.
This control differs from payload logging: payload logging keeps the log entry but drops the prompt and response text, whereas disabling request logging stops the entry from being written at all.
The file-claim check does not depend on payload logging: on a gateway that does not log payloads it still runs for Workspace turns, because it stores only its verdict (never prompt or answer text) and the conversation text is already part of the stored Workspace chat.
Request logging is about what is stored. The file-claim check runs for the tenant's turns either way: the answer is sent to the gateway's own self-hosted checking model on the Myra fleet (EU), which keeps no prompt or answer text, and the automatic re-dial and the "No file was created" note apply as for any tenant. With request logging off nothing about the check is stored in the request log — no entry is written, so no check keys (aig_cc_*) and no texts. On the gateway's own storage what remains is what any turn of the conversation keeps: the chat message (with the note, and after a re-dial the saved file and the rest of the answer) and the conversation's debug trace, which records re-dial steps as metadata only (no text unless the gateway's tracing includes bodies). A SIEM export the workspace configured itself is unaffected by this setting and receives the same event fields as for any turn.
Storage
Request logs are stored and retained by the Myra Security platform. Log retention and backend configuration are managed as part of your service agreement.
A platform administrator can also set a per-organisation retention: Organisations → Edit → Data & Retention → Request-log retention (days). Allowed values are whole numbers from 30 to 3650; leave it blank (or enter 0) to disable. Any other value is rejected with a 400. Once a log is older than this, its personal data (user, client IP, user agent, prompt and response) is permanently erased, which cannot be undone (for the optional ClickHouse copy see below); the billing record itself (provider, model, tokens, cost) is kept and deleted after 730 days, or after this period if it is longer. Tenant administrators cannot change this setting, and the deployment-wide switch is on by default in production and beta (off in dev and integration), so the next sweep erases permanently. When an organisation is purged, its request logs younger than 730 days are kept with the personal data removed and deleted automatically once they pass 730 days, whatever the retention setting was. For enterprise retention or export requirements, contact your Myra Security account team.
ClickHouse analytics sink (optional, off by default)
request_log is a high-volume, analytics-shaped table. The platform can additionally
mirror each entry to a column-oriented ClickHouse store, which compresses the repetitive
prompt history far better and answers time-range analytics/roll-up queries faster. This is a
best-effort shadow copy: the primary MySQL store stays authoritative and is the source
for the Request Logs view and all reads, and a ClickHouse outage or slowdown never affects,
delays, or fails a request — the mirror is written off the request path and its failures are
counted, never allowed to surface.
The mirror is an operator/deployment capability and is off by default; when off, behaviour is exactly as documented above with no ClickHouse involvement. It honours the same per-tenant control as the primary log: a tenant with request logging disabled is not mirrored to ClickHouse either.
When prompt and response logging is enabled for a request, the mirror also stores the prompt and response text, exactly as the primary store does; a request that opted out of payload logging is mirrored without any text. This applies only where the ClickHouse copy is enabled. There, the text is removed at the first ClickHouse background merge after 14 days (normally within hours), the same 14 days as the default of the primary store's operator-run payload expiry (see Content expired). The rest of the ClickHouse entry, including user, client IP and user agent, is kept for 730 days whatever the organisation's retention is. Nothing in the ClickHouse copy is ever deleted or anonymised: the retention sweep and organisation purge described above, and a user erasure, do not reach it; the text leaves it only by the 14-day expiry, the other personal fields only by the 730-day expiry. Both limits count from the request time, not from when the row is written in ClickHouse, so a row delivered late after an outage expires on the same date as if it had arrived at once. Rows still waiting on the gateway's local queue are removed from it once they were written to the queue more than 14 days ago; such a row never reaches the ClickHouse copy (an analytics gap only: the primary store keeps it and stays authoritative). A very large payload (over 16 MiB in total) or a heavily backlogged mirror queue is mirrored without the text, never at the cost of the request. Mirror batches that ClickHouse rejected are set aside on the gateway's disk and removed once they were created more than 14 days ago, also while ClickHouse is switched off.
See also
- Admin dashboard
- Gateway configuration —
log_payloads