|
| 1 | +--- |
| 2 | +title: Audit logs for Azure Database for MariaDB |
| 3 | +description: Describes the audit logs available in Azure Database for MariaDB, and the available parameters for enabling logging levels. |
| 4 | +author: ajlam |
| 5 | +ms.author: andrela |
| 6 | +ms.service: mariadb |
| 7 | +ms.topic: conceptual |
| 8 | +ms.date: 06/11/2019 |
| 9 | +--- |
| 10 | + |
| 11 | +# Audit Logs in Azure Database for MariaDB |
| 12 | + |
| 13 | +In Azure Database for MariaDB, the audit log is available to users. The audit log can be used to track database-level activity and is commonly used for compliance. |
| 14 | + |
| 15 | +> [!IMPORTANT] |
| 16 | +> Audit log functionality is currently in preview. |
| 17 | +
|
| 18 | +## Configure audit logging |
| 19 | + |
| 20 | +By default the audit log is disabled. To enable it, set `audit_log_enabled` to ON. |
| 21 | + |
| 22 | +Other parameters you can adjust include: |
| 23 | + |
| 24 | +- `audit_log_events`: controls the events to be logged. See below table for specific audit events. |
| 25 | +- `audit_log_exclude_users`: MariaDB users to be excluded from logging. Allows for at most four users. Max length of the parameter is 256 characters. |
| 26 | + |
| 27 | +| **Event** | **Description** | |
| 28 | +|---|---| |
| 29 | +| `CONNECTION` | - Connection initiation (successful or unsuccessful) <br> - User reauthentication with different user/password during session <br> - Connection termination | |
| 30 | +| `DML_SELECT`| SELECT queries | |
| 31 | +| `DML_NONSELECT` | INSERT/DELETE/UPDATE queries | |
| 32 | +| `DML` | DML = DML_SELECT + DML_NONSELECT | |
| 33 | +| `DDL` | Queries like "DROP DATABASE" | |
| 34 | +| `DCL` | Queries like "GRANT PERMISSION" | |
| 35 | +| `ADMIN` | Queries like "SHOW STATUS" | |
| 36 | +| `GENERAL` | All in DML_SELECT, DML_NONSELECT, DML, DDL, DCL, and ADMIN | |
| 37 | + |
| 38 | +## Access audit logs |
| 39 | + |
| 40 | +Audit logs are integrated with Azure Monitor Diagnostic Logs. Once you've enabled audit logs on your MariaDB server, you can emit them to Azure Monitor logs, Event Hubs, or Azure Storage. To learn more about how to enable diagnostic logs in the Azure portal, see the [audit log portal article](howto-configure-audit-logs-portal.md#set-up-diagnostic-logs). |
| 41 | + |
| 42 | +## Schemas |
| 43 | + |
| 44 | +The following sections describe what's output by MariaDB audit logs based on the event type. Depending on the output method, the fields included and the order in which they appear may vary. |
| 45 | + |
| 46 | +### Connection |
| 47 | + |
| 48 | +| **Property** | **Description** | |
| 49 | +|---|---| |
| 50 | +| `TenantId` | Your tenant ID | |
| 51 | +| `SourceSystem` | `Azure` | |
| 52 | +| `TimeGenerated` [UTC] | Time stamp when the log was recorded in UTC | |
| 53 | +| `Type` | Type of the log. Always `AzureDiagnostics` | |
| 54 | +| `SubscriptionId` | GUID for the subscription that the server belongs to | |
| 55 | +| `ResourceGroup` | Name of the resource group the server belongs to | |
| 56 | +| `ResourceProvider` | Name of the resource provider. Always `MICROSOFT.DBFORMARIADB` | |
| 57 | +| `ResourceType` | `Servers` | |
| 58 | +| `ResourceId` | Resource URI | |
| 59 | +| `Resource` | Name of the server | |
| 60 | +| `Category` | `MySqlAuditLogs` | |
| 61 | +| `OperationName` | `LogEvent` | |
| 62 | +| `event_class` | `connection_log` | |
| 63 | +| `event_subclass` | `CONNECT`, `DISCONNECT` | |
| 64 | +| `connection_id` | Unique connection ID generated by MariaDB | |
| 65 | +| `host` | Blank | |
| 66 | +| `ip` | IP address of client connecting to MariaDB | |
| 67 | +| `user` | Name of user executing the query | |
| 68 | +| `db` | Name of database connected to | |
| 69 | +| `\_ResourceId` | Resource URI | |
| 70 | + |
| 71 | +### General |
| 72 | + |
| 73 | +Schema below applies to GENERAL, DML_SELECT, DML_NONSELECT, DML, DDL, DCL, and ADMIN event types. |
| 74 | + |
| 75 | +| **Property** | **Description** | |
| 76 | +|---|---| |
| 77 | +| `TenantId` | Your tenant ID | |
| 78 | +| `SourceSystem` | `Azure` | |
| 79 | +| `TimeGenerated` [UTC] | Time stamp when tshe log was recorded in UTC | |
| 80 | +| `Type` | Type of the log. Always `AzureDiagnostics` | |
| 81 | +| `SubscriptionId` | GUID for the subscription that the server belongs to | |
| 82 | +| `ResourceGroup` | Name of the resource group the server belongs to | |
| 83 | +| `ResourceProvider` | Name of the resource provider. Always `MICROSOFT.DBFORMARIADB` | |
| 84 | +| `ResourceType` | `Servers` | |
| 85 | +| `ResourceId` | Resource URI | |
| 86 | +| `Resource` | Name of the server | |
| 87 | +| `Category` | `MySqlAuditLogs` | |
| 88 | +| `OperationName` | `LogEvent` | |
| 89 | +| `event_class` | `general_log` | |
| 90 | +| `event_subclass` | `LOG`, `ERROR`, `RESULT` | |
| 91 | +| `event_time` | Query start seconds in UNIX timestamp | |
| 92 | +| `error_code` | Error code if query failed. `0` means no error | |
| 93 | +| `thread_id` | ID of thread that executed the query | |
| 94 | +| `host` | Blank | |
| 95 | +| `ip` | IP address of client connecting to MariaDB | |
| 96 | +| `user` | Name of user executing the query | |
| 97 | +| `sql_text` | Full query text | |
| 98 | +| `\_ResourceId` | Resource URI | |
| 99 | + |
| 100 | +### Table access |
| 101 | + |
| 102 | +| **Property** | **Description** | |
| 103 | +|---|---| |
| 104 | +| `TenantId` | Your tenant ID | |
| 105 | +| `SourceSystem` | `Azure` | |
| 106 | +| `TimeGenerated` [UTC] | Time stamp when the log was recorded in UTC | |
| 107 | +| `Type` | Type of the log. Always `AzureDiagnostics` | |
| 108 | +| `SubscriptionId` | GUID for the subscription that the server belongs to | |
| 109 | +| `ResourceGroup` | Name of the resource group the server belongs to | |
| 110 | +| `ResourceProvider` | Name of the resource provider. Always `MICROSOFT.DBFORMARIADB` | |
| 111 | +| `ResourceType` | `Servers` | |
| 112 | +| `ResourceId` | Resource URI | |
| 113 | +| `Resource` | Name of the server | |
| 114 | +| `Category` | `MySqlAuditLogs` | |
| 115 | +| `OperationName` | `LogEvent` | |
| 116 | +| `event_class` | `table_access_log` | |
| 117 | +| `event_subclass` | `READ`, `INSERT`, `UPDATE`, or `DELETE` | |
| 118 | +| `connection_id` | Unique connection ID generated by MariaDB | |
| 119 | +| `db` | Name of database accessed | |
| 120 | +| `table` | Name of table accessed | |
| 121 | +| `sql_text` | Full query text | |
| 122 | +| `\_ResourceId` | Resource URI | |
| 123 | + |
| 124 | +## Next steps |
| 125 | + |
| 126 | +- [How to configure audit logs in the Azure portal](howto-configure-audit-logs-portal.md) |
0 commit comments