Auditing SQL Server on Amazon EC2 or Amazon RDS Custom DB instances
This section provides information about auditing options for SQL Server on Amazon EC2 and Amazon RDS Custom, including creating server and database audits, viewing audit logs, and monitoring results.
Prerequisites
-
Database login with
ALTER ANY SERVER AUDIT
orCONTROL SERVER
permission
Supported versions
-
Any edition of SQL Server version 2016 and later
Using C2 audit mode
C2 audit mode audits events such as user logins, stored procedure calls, and creation and
deletion of objects. This mode can generate lot of data because it audits everything or nothing.
C2 audit logs are stored in the default data directory of the SQL Server instance. Each log file
can be a maximum of 200 MB. A new file is automatically created when this limit is reached. You
can enable C2 auditing by using SQL Server Management Studio. For more information, see the
Microsoft SQL Server documentation
Important
Microsoft plans to remove C2 audit mode in a future version of SQL Server. We recommend that you avoid using this feature.
To use C2 audit mode to audit failed logins:
-
In SQL Server Management Studio, connect to the SQL Server instance that you want to enable auditing for.
-
Select the SQL Server instance, right-click and choose Properties, and then choose Security.
-
For Login auditing, choose a configuration option. You can audit failed logins only, successful logins only, both, or none. (The default is failed logins only.)
-
For Options, select Enable C2 audit tracing.
Creating and viewing audits
Creating server audits
A server audit in SQL Server collects instance-level or database-level actions to monitor. Audit output is saved to an audit destination file path, a Windows security log, or an application log.
To create a server audit:
-
In SQL Server Management Studio, in Object Explorer, expand Security, right-click Audits, and then choose New Audit. This creates a new SQL Server Audit object for server-level auditing.
-
For Audit destination, choose a file, a security log, or an application log.
-
If you selected a file as the target, specify the location of the folder.
-
Configure other options, and then choose OK.
-
To enable the audit, right-click the new audit configuration, and then choose Enable Audit.
For more information, see the Microsoft SQL Server documentation
Creating server audit specifications
The server audit specification collects many server-level action groups raised by the SQL Server Extended Events feature. You can include audit action groups in a server audit specification. These actions are sent to the audit that records them in the target file or log.
To create a server audit specification:
-
In SQL Server Management Studio, in Object Explorer, expand Security, right-click Server Audit Specifications, and then choose New Server Audit Specification.
-
For Audit, choose the server audit you created earlier.
-
For Actions, choose the audit action type that specifies the server-level audit action groups and audit actions that you want to capture, and then choose OK.
-
To enable the server audit specification, right-click the new specification, and then choose Enable Server Audit Specification.
For more information, see Create a Server Audit and Server Audit Specification
Creating database audit specifications
You can create a database audit specification object for database-level auditing. This specification specifies the database-level audit action groups and audit actions to capture.
To create a database audit specification:
-
In SQL Server Management Studio, in Object Explorer, expand the database that you want to audit.
-
Expand the Security folder, right-click Database Audit Specifications, and then choose New Database Audit Specification.
-
For Actions, configure one or more database audit action types. Select the statements that you want to audit (such as DELETE or INSERT) and the object class to perform the action on.
-
When your selections are complete, choose OK.
-
To enable the database audit specification, right-click the new specification, and then choose Enable Database Audit Specification.
For more information, see Create a server audit and database audit specification
Viewing SQL Server audit logs
To view audit logs:
-
In SQL Server Management Studio, right-click the SQL Server Audit object, and then choose View Audit Logs.
The Log File Viewer displays the audit log regardless of its location (a file or the Windows Event Log).
-
To customize the log entries that are displayed, choose Filter.
-
To export the log to a log file, choose Export.
-
When you've finished viewing the log, choose Close.
For more information, see the Microsoft SQL Server documentation
Monitoring
You can monitor audit logs that are logged to an audit file, an application or security
event log, or an audit table in the database by using monitoring solutions such as Nagios