Audit log
With --audit-log, every request produces one JSON line in a dedicated file
(- for stdout), separate from the operational log. Authentication failures
and denials produce events too, and so do calls over
Flight SQL, with the same fields.
{"ts":"...","event":"query","request_id":"1a1147f8f9b0...","user":"analyst","roles":["analyst"], "remote_addr":"10.0.0.7","database":"sales","statement_type":"SELECT", "sql":"SELECT count(*) FROM orders WHERE amount > ?","sql_sha256":"...","params_count":0, "tables":["sales.main.orders"],"resolved":true,"decision":"allow","decided_by":"policy", "policy_sha256":"...","status":200,"rows":1,"bytes":42, "timing_ms":{"queue":0,"inspect":1.2,"authorize":0.25,"execute":1.7,"total":3.3}, "curral_version":"0.7.0"}Fields worth knowing
Section titled “Fields worth knowing”decision:allow,denyorerror.decided_by:policy,engine,auth,queue,audit,request,protection,concurrencyordelegation.actor,identity,caller: on a request a service makes on someone’s behalf,useris the effective identity,actorthe delegating key andidentitythe context it sent. A shared key’s audit-only context goes incaller.policy_sha256: proves which version of the rules decided.doc: the document id ondoc_create,doc_updateanddoc_deleteevents, written for each change to semantic documents.event:queryfor a statement,schemafor a listing (including the database tree an IDE loads over Flight SQL) andpreparewhen a Flight SQL client prepares a statement: inspected and authorized, not run, and kept out of the query metrics. Running it adds its ownqueryevent. A missing or refused execution identity producesdelegation_denied.request_id: also in theX-Request-Idresponse header and the operational log.
Personal data
Section titled “Personal data”By default SQL literals become ?, because they may contain personal data.
Parameter values are never logged, only their count, and passwords never
appear.
--audit-sql |
|
|---|---|
redacted (default) |
literals replaced by ? |
full |
the SQL as sent |
hash |
only sql_sha256 |
If the SQL uses constructs the tokenizer cannot read safely, only the hash is kept.
Fail-closed
Section titled “Fail-closed”Before executing, curral reserves room in the audit queue
(--audit-queue, 4096 events). If the file cannot be written (full disk,
permissions) or the queue is full, the query gets 503 and does not run.
Writes to semantic documents are refused the same way.
Recovery is checked every 5 seconds and logged as audit_recovered.
A process crash between a write’s commit and its event being recorded can still lose that event.
Rotation
Section titled “Rotation”Move the file and send SIGHUP. The new file starts with an
audit_reopened event; copytruncate is not needed.