Sub topic 10
What audit logs record and why they matter
This chapter explains what the Unity Catalog audit log contains and where to find it. It also covers what the log cannot tell you. It assumes you know basic SQL, can run queries in a Databricks notebook or SQL warehouse, and understand the catalog.schema.table namespace. It also assumes you know what GRANT does. The next chapter covers the table's columns in detail, and the chapter after that covers query patterns.
Lineage and audit answer different questions
Lineage records how data flows. Audit logs record what people and services did. The two overlap in places, but they are not interchangeable.
| Question | Best source |
|---|---|
| Which tables feed `main.sales.daily_revenue`? | Lineage |
| Who dropped `main.sales.orders` last Tuesday? | Audit log |
| Which dashboards break if I rename a column? | Lineage |
| Who changed the grants on a schema? | Audit log |
| Did a user try to read a table they were denied? | Audit log |
Many real investigations need both. Lineage tells you what is affected, and the audit log tells you who acted and when. A later chapter in this tutorial combines them.
What an audit log is
An audit log is an append-only record of events. Each row says that a specific identity performed a specific action on a specific service at a specific time, and that the platform answered with a specific result.
In Databricks, audit events are exposed through the system table system.access.audit. The table is a queryable copy of events from several sources, including workspace-level services and account-level activity. It also includes Unity Catalog, which is the part this tutorial focuses on.
Each event captures these things:
- When: a timestamp (
event_time) and a date (event_date) used for partition filtering. - Who: the calling identity, held in the
user_identitystruct, which includes the email. - From where: the source IP address and the user agent string.
- What: the
service_name(for exampleunityCatalog) and theaction_name(for examplegetTable). - On what: the
request_paramsmap, whose keys depend on the action. For table actions it usually includes the full table name. - With what result: the
responsestruct, which holds astatus_codeand, on failure, an error message.
The next chapter walks through every column. For now, remember the pattern: who did what, to which object, when, and whether it worked.
Which Unity Catalog actions show up
Unity Catalog logs actions on its securables. A securable is any object that has privileges attached, such as a catalog, schema, table, volume, or external location. Typical events fall into these groups:
- Metadata reads:
getTable,getSchema,getCatalog,listTables. - Object changes:
createTable,deleteTable,createSchema,deleteSchema. - Permission changes:
updatePermissionsrecords changes to grants. - Credential issuance:
generateTemporaryTableCredentialand similar actions, which occur when a compute resource asks Unity Catalog for short-lived storage access in order to read or write table data.
Other services write to the same table. For example, account-level sign-in events and workspace events such as cluster and job actions share the table. You separate them with the service_name column. A first exploration query shows what your account actually produces:
SELECT
service_name,
count(*) AS event_count
FROM system.access.audit
WHERE event_date >= current_date() - INTERVAL 1 DAYS
GROUP BY service_name
ORDER BY event_count DESC;The exact list of services depends on your account and on which logging options are enabled. Some very detailed events, such as individual notebook commands, are only recorded when verbose audit logging is turned on for the workspace. If you expect an event and cannot find it, check that setting before assuming the log is broken.
What the audit log does not tell you
The audit log is a record of control-plane style events. It has gaps that surprise people.
- It does not record data values. You can see that a user asked about a table. You cannot see which rows they received.
- A metadata event is not a data read. A
getTableevent means someone requested the table's metadata. This happens when a user opens the table in Catalog Explorer, and when a query is planned. It does not prove that any rows were read. To approximate real data access you need to look at credential-issuance events, query history, or the lineage tables, each of which has its own limits. - It does not record business meaning. It cannot say whether a change was approved. It only says the change happened.
- It has finite retention. System table data is not kept forever. Databricks documents a retention period for the audit table, so confirm the current value in the documentation for your cloud. If a regulation requires longer retention, copy the data into your own Delta table on a schedule.
Why audit logs matter
Audit logs are useful because they are a shared source of truth that the people being audited cannot easily edit. Common uses are:
- Security investigation. After a suspected leak, you can list every identity that touched a table in a window and from which IP addresses.
- Change tracking. When a table disappears or a grant changes, the log names the actor and the time.
- Access reviews. Periodic reviews ask whether granted access is actually used. The log shows which principals acted, so unused access stands out.
- Failure and probing detection. Repeated responses with a status code of 400 or higher from one user can mean a permission problem or someone testing boundaries.
- Compliance evidence. Auditors for frameworks such as SOC 2 or GDPR ask for proof that access to sensitive data is controlled and monitored. A query result over this table is that proof.
How events reach the table
You do not install an agent or configure a collector for Unity Catalog events. The platform writes them as actions happen, and they appear in the system table after a short delay. The figure shows the path from an action to an analyst's query.
Note that the privilege check happens before the result is known, and the event is recorded either way. That is why denied requests appear in the log with an error status. They are some of the most informative rows.
Getting access to the table
Ordinary users cannot read the system catalog by default. An account admin must enable the relevant system schema (access) for the metastore. After that, a privileged user grants read access explicitly. Grant to a group, not to individuals, and grant only what the group needs:
GRANT USE CATALOG ON CATALOG system TO `data-governance`;
GRANT USE SCHEMA ON SCHEMA system.access TO `data-governance`;
GRANT SELECT ON TABLE system.access.audit TO `data-governance`;The audit table can contain user emails, IP addresses, and object names, so treat it as sensitive. Granting SELECT on the whole system.access schema would also expose other tables there, such as the lineage tables. Granting on the single table keeps the permission narrow.
A first useful query
Here is a small query that exercises the pattern: filter by service, filter by date, and read the identity and result.
SELECT
event_time,
user_identity.email AS user_email,
action_name,
request_params.full_name_arg AS table_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'
AND event_date >= current_date() - INTERVAL 7 DAYS
ORDER BY event_time DESC;Three habits in this query matter on a large table:
- Always filter on
event_date. It lets the engine skip most of the data, so the query is faster and cheaper. - Always filter on
service_namebefore looking ataction_name, because the same action name can exist in more than one service. - Read
request_paramskeys by name. The available keys differ by action, so a key that works forgetTablemay be null for another action.
Common mistakes
- Searching for an action name without confirming it exists. Run a
SELECT DISTINCT action_namequery for the service first. - Forgetting the date filter and scanning the entire retention window.
- Assuming an empty result means nothing happened. It may mean the system schema is not enabled, the retention window has passed, or the event is of a type that requires verbose logging.
- Reading a successful
getTableevent as proof of a data read.
Exercise
A manager asks, "Show me everyone who read the customers table last month." You find getTable events for the table from 14 users. Why is it risky to report that all 14 read the data, and what would you do next?
Show answer
A getTable event records a metadata request, which also occurs when someone merely browses the table in Catalog Explorer or when a query is planned. It does not show that rows were returned. Report the 14 as "users who requested the table's metadata," then look for stronger evidence of data access. Examples are credential-issuance events such as generateTemporaryTableCredential, query history, or lineage entries. Also note the retention limit, because "last month" must fall inside the retained window.
Exercise
You run an audit query and get no rows, even though you know a table was dropped yesterday. Name three possible causes to check.
Show answer
First, the access system schema may not be enabled for the metastore, or your group may lack SELECT on the table. Second, the query may be filtering on the wrong service_name, action_name, or request_params key. Third, the event may have been recorded under a different workspace or account level than you assumed, or the data may not have landed yet because of the ingestion delay. Checking SELECT DISTINCT action_name for the service helps rule out the second cause.