Sub topic 14
Access Reviews and Ongoing Compliance Monitoring
This chapter assumes you can write SQL against Unity Catalog system tables. It also assumes you know the system.access.audit columns from the earlier chapters and that your governance group already has the grants shown there. Here you will turn those queries into a repeatable review process.
What an access review asks
An access review checks whether the people and groups who can reach sensitive data are the ones who should. Audit logs give you evidence of what actually happened. Lineage tells you which tables deserve the closest look, because a table fed by a sensitive source often inherits the same risk.
A practical review answers three questions:
- Who accessed the sensitive tables in the review period?
- Were any requests denied, and does a pattern suggest misconfigured permissions or probing?
- Did anyone change who can see the data?
A review cycle
The cycle below runs on a schedule, such as monthly for most tables and weekly for the most sensitive ones.
Start with the sensitive tables. Run the downstream query from the lineage chapter against each one, so that copies and aggregates are in scope too. Then run the audit queries against the full list.
Queries for the review
The first query reuses the access query from the audit chapter. It shows who requested metadata for one table in the last seven days.
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;Compare the users in the result with the list of people who are expected to use the table. Anyone unexpected is a finding to raise with the data owner.
The second query summarizes failed requests over 30 days.
SELECT
user_identity.email AS user_email,
action_name,
count(*) AS event_count
FROM system.access.audit
WHERE service_name = 'unityCatalog'
AND event_date >= current_date() - INTERVAL 30 DAYS
AND response.status_code >= 400
GROUP BY user_identity.email, action_name
ORDER BY event_count DESC;A high count for one user and one action can mean a legitimate person is missing a grant. It can also mean someone is trying objects they should not touch. Check with the user or their manager before you decide which.
Turning queries into monitoring
A review is a point-in-time check. Ongoing monitoring runs the same queries on a schedule and tells someone when the results need attention.
- Save each query in Databricks SQL and schedule it with a job or a SQL alert.
- Alert on a threshold, such as more than a set number of failed requests per user per day.
- Send alerts to the data governance group, not to individual engineers.
- Keep the output of each review. The audit table is retained for a limited period, so a saved copy is your record for later audits.
Limits to keep in mind
- A
getTableevent shows that metadata was requested. It does not prove that rows were read. - Lineage can miss some paths, as described in the limits chapter, so a downstream list may be incomplete.
- Review results depend on the grants from earlier chapters. If a reviewer cannot read the system tables, the queries return an error or no rows.
Exercise
A scheduled query shows one user with 240 failed Unity Catalog requests in 30 days. What two explanations should you consider, and what should you do before changing any permissions?
Show answer
The user may legitimately need access but is missing a grant, or the user may be probing objects they should not access. Contact the user or their manager and the data owner to confirm the intent, then either add the correct grant or follow your security process. Save the query output as evidence either way.
Exercise
Why should you run the downstream lineage query before the audit queries in a review?
Show answer
Lineage lists tables derived from the sensitive source. Adding them to the audit queries covers copies and aggregates that may expose the same data.