Edit

How to configure SQL audit logs

Applies to: ✅ Warehouse in Microsoft Fabric

Auditing in Fabric Data Warehouse provides enhanced security and compliance capabilities by tracking and recording database events.

You can configure SQL audit logs in Fabric Data Warehouse in the Fabric portal or via REST API.

Prerequisites

To configure SQL audit logs for Fabric Data Warehouse, you need the following items:

  • A Fabric workspace with an active capacity or trial capacity.
  • Access to a Warehouse item within a workspace.
  • Audit permission to configure and query audit logs. For more information, see Permissions.

Configure SQL audit logs

You can configure SQL audit logs by using the Fabric portal or REST API.

  1. In your Fabric workspace, select the Settings of your warehouse item.

  2. Select the SQL audit logs page.

  3. Enable the setting Save events to SQL audit logs.

    Screenshot from the Fabric portal of the setting to enable.

    By default, all actions are enabled and retained for nine years.

  4. Under Events to record, select which events the SQL audit logs capture. Select the event categories or individual audit action groups you want to capture. Only select the events your organization requires to optimize storage and relevance.

    Screenshot from the Fabric portal of the recording and retention options, the Events to record section.

  5. Optionally, enter a Predicate Expression to filter events, such as excluding activity from a known service principal or automation identity. Use the syntax described in Predicate expression syntax.

    Screenshot from the Fabric portal of the Predicate Expression option.

    Important

    Predicate filtering only applies to events already selected under Events to record. For example, to filter SELECT statements, you must also enable Batch Was Completed.

  6. Specify a desired log retention period in Years, Months, and Days.

    Screenshot from the Fabric portal of the Log retention options.

  7. Select Save to apply your settings.

Your warehouse now records the selected audit events and stores the logs securely in OneLake.

Query audit logs

SQL audit log data is stored in .XEL files in the OneLake. You can access this data by using the sys.fn_get_audit_file_v2 Transact-SQL (T-SQL) function. For more information about how audit files are stored in the OneLake, see SQL audit logs in Fabric Data Warehouse.

From the SQL query editor or any query tool such as SQL Server Management Studio (SSMS) or the MSSQL extension for Visual Studio Code, use the following sample T-SQL queries. Be sure to provide your own <workspaceId> and <warehouseId>.

SELECT * 
FROM sys.fn_get_audit_file_v2
('https://onelake.blob.fabric.microsoft.com/<workspaceId>/<warehouseId>/Audit/sqldbauditlogs/'
, default, default, default, default);

To filter logs by time range, use the following query:

SELECT * 
FROM sys.fn_get_audit_file_v2
('https://onelake.blob.fabric.microsoft.com/<workspaceId>/<warehouseId>/Audit/sqldbauditlogs/'
, default, default, '2025-03-30T08:40:40Z', '2025-03-30T09:10:40Z');