Sub topic 11
Reading the system.access.audit table
This chapter explains how the system.access.audit table is laid out and how to read one row. It assumes you can write SELECT queries with WHERE, GROUP BY, and ORDER BY. It also assumes you have used a SQL warehouse and understand the catalog.schema.table namespace. You should also know from the previous chapter that audit logs record who did what, and when.
What one row represents
Each row in system.access.audit is one audit event. An event is a single action that a user, service principal, or Databricks itself performed against a service in your account. Examples are a table metadata request, a permission change, a notebook run, or a failed login.
The table is a system table. Databricks owns it and fills it for you, and you only read it. Each row says who acted (identity), on what (service and action), with what details (request parameters), and what happened (response).
You must be granted access before you can query it. The GRANT statements shown in the Topic Spine give a group USE CATALOG on system, USE SCHEMA on system.access, and SELECT on the table.
Inspect the schema first
Look at the real columns in your account before you write filters. The schema can gain columns over time.
DESCRIBE TABLE system.access.audit;The columns you will use most often are listed here.
| Column | Type | What it holds |
|---|---|---|
| `event_time` | timestamp | When the event happened (UTC). |
| `event_date` | date | The date of the event. Use it to limit how much data is scanned. |
| `event_id` | string | A unique ID for the event. |
| `account_id` | string | The Databricks account the event belongs to. |
| `workspace_id` | string | The workspace where the event happened. Account-level events have a value of 0. |
| `service_name` | string | The service that handled the request, such as `unityCatalog` or `accounts`. |
| `action_name` | string | The operation, such as `getTable` or `createCatalog`. |
| `user_identity` | struct | Who made the request. Holds `email` and `subject_name`. |
| `source_ip_address` | string | The IP address the request came from. |
| `user_agent` | string | The client software that made the request. |
| `session_id` | string | The session the request belongs to. |
| `request_id` | string | An ID that ties the request to a service-side record. |
| `request_params` | map of string to string | The parameters of the request. Keys depend on the action. |
| `response` | struct | Holds `status_code`, `error_message`, and `result`. |
| `audit_level` | string | Whether the event is workspace-level or account-level. |
The exact list of columns may differ slightly from this table. Treat the output of DESCRIBE TABLE as the source of truth.
How the pieces fit together
The next diagram shows how one event is built from the identity, the action, the parameters, and the response.
service_name and action_name
Always start by narrowing the table with service_name. It groups events by the part of the platform that produced them. Then use action_name to pick one operation.
For Unity Catalog, the service name is unityCatalog. Its actions describe both reads and changes of metadata. Examples are getTable, createTable, deleteTable, updatePermissions, and getCatalog.
Do not guess action names. List them from your own data:
SELECT
action_name,
count(*) AS event_count
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND event_date >= current_date() - INTERVAL 7 DAYS
GROUP BY action_name
ORDER BY event_count DESC
LIMIT 50;This query shows which actions occur in your account and how often. Run it once, and keep the names you need for later filters.
Who made the request
user_identity is a struct, so you read its fields with dot notation. The most useful field is email. For a person it holds their login. For a service principal it holds the application ID. Some events come from Databricks itself, and the identity can be a system value instead of a real email address.
SELECT
event_time,
user_identity.email AS user_email,
source_ip_address,
user_agent,
action_name
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND event_date >= current_date() - INTERVAL 1 DAYS
ORDER BY event_time DESC
LIMIT 20;source_ip_address and user_agent help you tell a browser session from an API client or a connector. A service principal that suddenly appears from an unknown IP address is worth a closer look.
request_params: the object and the details
request_params is a map from string keys to string values. The keys change with the action, so there is no fixed list. A getTable event carries the table name in full_name_arg. Other Unity Catalog actions use keys such as name_arg, securable_type, or changes.
You can read a key with dot notation, as the Topic Spine query does, or with bracket syntax. Both forms return the value for the key, or NULL if the key is missing.
SELECT
event_time,
action_name,
request_params.full_name_arg AS table_name_dot,
request_params['full_name_arg'] AS table_name_bracket
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND action_name = 'getTable'
AND event_date >= current_date() - INTERVAL 1 DAYS
LIMIT 10;Because the map is untyped, find out which keys exist for an action before you rely on one. You can list them like this:
SELECT DISTINCT
explode(map_keys(request_params)) AS param_key
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND action_name = 'getTable'
AND event_date >= current_date() - INTERVAL 7 DAYS;response: did it work?
response is a struct with three fields.
status_codeis an HTTP-style number. A value of 200 means success. Values of 400 and above are failures. A 403 usually means the user lacked permission, and a 404 means the object was not found.error_messageholds the text of the failure, when there is one.resultholds extra output for some actions.
A request that was denied is still recorded. This makes the table useful for security work, since repeated 403 responses from one user can show a permission problem or someone probing for data.
SELECT
event_time,
user_identity.email AS user_email,
action_name,
response.status_code,
response.error_message
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND response.status_code >= 400
AND event_date >= current_date() - INTERVAL 7 DAYS
ORDER BY event_time DESC
LIMIT 50;Always filter by time
The audit table can be very large. event_date is the column to filter on, because it lets the engine skip data outside your date range. Put an event_date condition in every query, even when you also filter on event_time.
SELECT
count(*) AS events
FROM system.access.audit
WHERE event_date BETWEEN date'2026-11-01' AND date'2026-11-30'
AND service_name = 'unityCatalog';If you filter only on event_time, the query may scan far more data than you need. That makes it slower and more expensive on the warehouse.
Edge cases to know
- Delay. Events do not appear the instant they happen. Wait a short time before you look for a fresh event, and do not conclude that an action was missed because it is not there yet.
- Retention. System table history has a limited retention period. For audit data this is typically a year. Export rows you need to keep for longer, for example into a table you own.
- Scope. A single
audittable can hold events from several workspaces in the account. Filter onworkspace_idwhen you only care about one of them. Account-level events show aworkspace_idof 0. - Read access is not the same as a recorded read. Metadata calls such as
getTableshow that someone asked about a table. They do not prove that someone read the rows. Use other tables, such as lineage, to see data reads. - Names change. Action names and request parameter keys can differ between services and may change as the platform evolves. Re-check them when a query stops returning rows.
A reusable starting query
You can use this pattern as the base for most audit work. It selects the main fields, limits the date range, and narrows to one service.
SELECT
event_time,
workspace_id,
user_identity.email AS user_email,
service_name,
action_name,
request_params,
response.status_code AS status_code,
response.error_message AS error_message
FROM system.access.audit
WHERE event_date >= current_date() - INTERVAL 3 DAYS
AND service_name = 'unityCatalog'
ORDER BY event_time DESC
LIMIT 100;Once it works, add a filter on action_name, then a filter on one request_params key, then a condition on response.status_code. Add one filter at a time and confirm that the results still make sense.
Exercise
You run a query for events where request_params.full_name_arg = 'main.sales.daily_revenue' and get no rows. List two likely reasons, and say what you would check for each.
Show answer
First, the filter may be missing the right service_name or action_name, or the key may not exist for that action. Check the keys with explode(map_keys(request_params)) for that action. Second, the date range may be wrong or too narrow, or the events may not have arrived yet. Widen the event_date filter and confirm that rows exist for the table in that window. A table name written with different casing or in a different catalog would also return nothing, so compare it against the names you see in a sample of getTable rows.
Exercise
Write a query that returns the 10 users with the most failed Unity Catalog requests (status code 400 or higher) over the last 14 days. Which column do you filter on first to keep the scan small?
Show answer
SELECT useridentity.email AS useremail, count(*) AS failedrequests FROM system.access.audit WHERE servicename = 'unityCatalog' AND eventdate >= currentdate() - INTERVAL 14 DAYS AND response.statuscode >= 400 GROUP BY useridentity.email ORDER BY failedrequests DESC LIMIT 10; The column to filter on first is `eventdate`, because it limits how much data the engine reads.