Sub topic 3
Reading the `system.access.audit` Table
Assume you know SELECT, filtering, grouping, and Unity Catalog names such as catalog.schema.table. The audit table records events involving workspace and Unity Catalog operations. It helps answer who performed an action, when it happened, which object was involved, and whether the request succeeded.
Reading the audit table
Important columns include:
event_time: when the event occurred.event_date: the event date, useful for partition filtering.user_identity.email: the user or service principal.service_name: the service that handled the request.action_name: the operation, such asgetTable.request_params: request details, often includingfull_name_arg.response.status_code: the result status.
SELECT
event_time,
user_identity.email AS user_email,
service_name,
action_name,
request_params.full_name_arg AS object_name,
response.status_code
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND event_date >= current_date() - INTERVAL 7 DAYS
ORDER BY event_time DESC
LIMIT 100;Use event_date in time filters even when you also select event_time. This usually reduces the amount of data scanned.
Common audit queries
To review metadata access for one table:
SELECT
event_time,
user_identity.email AS user_email,
action_name,
response.status_code
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND action_name = 'getTable'
AND request_params.full_name_arg = 'main.sales.daily_revenue'
ORDER BY event_time DESC;For changes, filter on the relevant catalog operations in your environment:
SELECT
event_time,
user_identity.email AS user_email,
action_name,
request_params.full_name_arg AS object_name,
response.status_code
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND action_name IN ('createTable', 'alterTable', 'deleteTable')
AND event_date >= current_date() - INTERVAL 30 DAYS
ORDER BY event_time DESC;Denied or failed requests are useful for finding broken permissions and unusual access attempts:
SELECT
user_identity.email AS user_email,
action_name,
count(*) AS failures
FROM system.access.audit
WHERE event_date >= current_date() - INTERVAL 30 DAYS
AND response.status_code >= 400
GROUP BY user_identity.email, action_name
ORDER BY failures DESC;Combining lineage and audit data
Lineage shows dependencies. Audit data shows activity. Together, they support change-impact analysis.
For example, first query system.access.table_lineage for downstream tables of main.sales.orders. Then query system.access.audit for recent reads or changes to those tables. This separates technical dependency from actual recent use.
Access reviews and monitoring
Schedule reports that summarize:
- Users accessing sensitive tables.
- Successful and denied requests.
- Catalog changes and their actors.
- Objects with lineage but no recent approved use.
Restrict access to the audit data itself. Grant reviewers only the system catalog, schema, and table privileges they need. Store periodic summaries when retention or reporting requirements exceed the available system-table history.
Exercise
Which two data sources should you combine to assess the effect of changing a source table?
Show answer
Use table or column lineage to find dependent data assets, then use audit events to identify recent users, operations, changes, and denied requests.