Relational Database ServiceRelational Database Service

Compute
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
Domain Name Service
VPC Endpoint
Cloud Connect
Enterprise Switch
Security & Compliance
Anti-DDoS
Web Application Firewall
Host Security Service
Data Encryption Workshop
Database Security Service
Advanced Anti-DDoS
Data Security Center
Container Guard Service
Situation Awareness
Managed Threat Detection
Compass
Cloud Certificate Manager
Anti-DDoS Service
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GaussDB NoSQL
GaussDB(for MySQL)
Distributed Database Middleware
GaussDB(for openGauss)
Developer Services
ServiceStage
Distributed Cache Service
Simple Message Notification
Application Performance Management
Application Operations Management
Blockchain
API Gateway
Cloud Performance Test Service
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
DevCloud
ProjectMan
CodeHub
CloudRelease
CloudPipeline
CloudBuild
CloudDeploy
Cloud Communications
Message & SMS
Cloud Ecosystem
Marketplace
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP License Service
Support Plans
Customer Operation Capabilities
Partner Support Plans
Professional Services
enterprise-collaboration
Meeting
IoT
IoT
Intelligent EdgeFabric
DeveloperTools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Updated at: Apr 02, 2022 GMT+08:00

Viewing and Downloading Audit Logs

The SQL audit function is enabled by default for Microsoft SQL Server DB instances and cannot be disabled. Major change operations on services, databases, and tables are recorded in audit log files for future query and download.

SQL Server Audit enables you to audit server-level and database-level groups of events and individual events. SQL Server audits consist of zero or more audit action items. Table 1 shows the server-level audit action groups and provides the equivalent SQL Server Event Class where applicable. For more information, see SQL Server Audit Action Groups and Actions.

  • The maximum size of an audit log file is 20 MB. Up to 20 audit log files can be displayed.
  • Microsoft SQL Server 2008 Web and Standard Editions do not support the SQL audit function.
  • No audit is performed for job creation and modifications on parameters, server attribute parameters, SQL agent attribute parameters, and database extended attribute parameters.
  • The succeeded parameter displayed in the audit log indicates whether the event is triggered successfully. Its value cannot be null. For all events except login events, only the success or failure of the permission check (not the operation) is reported.
  • For details about the audit of table-level and column-level architecture changes, see the audit result of the SQL Server engine.
Table 1 Audit action groups

Action Group Name

Description

APPLICATION_ROLE_CHANGE_PASSWORD_GROUP

This event is raised whenever a password is changed for an application role.

DATABASE_CHANGE_GROUP

This event is raised when a database is created, altered, or dropped.

DATABASE_OBJECT_CHANGE_GROUP

This event is raised when a CREATE, ALTER, or DROP statement is executed on database objects, such as schemas.

DATABASE_OBJECT_OWNERSHIP_CHANGE_GROUP

This event is raised when a change of owner for objects within database scope.

DATABASE_OBJECT_PERMISSION_CHANGE_GROUP

This event is raised when a GRANT, REVOKE, or DENY has been issued for database objects, such as assemblies and schemas.

DATABASE_OWNERSHIP_CHANGE_GROUP

This event is raised when you use the ALTER AUTHORIZATION statement to change the owner of a database.

DATABASE_PERMISSION_CHANGE_GROUP

This event is raised whenever a GRANT, REVOKE, or DENY is issued for a statement permission by any user in SQL Server for database-only events such as granting permissions on a database.

DATABASE_PRINCIPAL_CHANGE_GROUP

This event is raised when principals, such as users, are created, altered, or dropped from a database.

DATABASE_ROLE_MEMBER_CHANGE_GROUP

This event is raised whenever a login is added to or removed from a database role.

FAILED_LOGIN_GROUP

Indicates that a principal tried to log on to a SQL Server database and failed. Events in this class are raised by new connections or by connections that are reused from a connection pool.

LOGIN_CHANGE_PASSWORD_GROUP

This event is raised whenever a login password is changed by way of ALTER LOGIN statement or sp_password stored procedure.

SCHEMA_OBJECT_CHANGE_GROUP

This event is raised when a CREATE, ALTER, or DROP operation is performed on a schema.

SCHEMA_OBJECT_OWNERSHIP_CHANGE_GROUP

This event is raised when the permissions to change the owner of schema object (such as a table, procedure, or function) is checked.

SCHEMA_OBJECT_PERMISSION_CHANGE_GROUP

This event is raised whenever a grant, deny, revoke is performed against a schema object.

SERVER_OBJECT_CHANGE_GROUP

This event is raised for CREATE, ALTER, or DROP operations on server objects.

SERVER_OBJECT_OWNERSHIP_CHANGE_GROUP

This event is raised when the owner is changed for objects in server scope.

SERVER_OBJECT_PERMISSION_CHANGE_GROUP

This event is raised whenever a GRANT, REVOKE, or DENY is issued for a server object permission by any principal in SQL Server.

SERVER_PERMISSION_CHANGE_GROUP

This event is raised when a GRANT, REVOKE, or DENY is issued for permissions in the server scope.

SERVER_PRINCIPAL_CHANGE_GROUP

This event is raised when server principals are created, altered, or dropped.

SERVER_ROLE_MEMBER_CHANGE_GROUP

This event is raised whenever a login is added or removed from a fixed server role.

SERVER_STATE_CHANGE_GROUP

This event is raised when the SQL Server service state is modified.

USER_CHANGE_PASSWORD_GROUP

This event is raised whenever the password of a contained database user is changed by using the ALTER USER statement (SQL Server 2008 is not involved).

Querying Audit Logs

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Database > Relational Database Service. The RDS console is displayed.
  4. On the Instance Management page, click the target DB instance.
  5. In the navigation pane on the left, choose Logs. On the System Logs page, click Download.
  6. On the Download page, record the names of audit logs.

    Figure 1 SQL Server audit logs

    The audit log name starts with RDSAudit. The system automatically adds the GUID and timestamp to the file name as a suffix.

  7. Connect to the DB instance through the Microsoft SQL Server client. For details, see Connecting to a DB Instance Through a Public Network.
  8. After the DB instance is connected, run the following command to view details about SQL audit logs:

    select * from msdb.dbo.rds_fn_get_audit_file(file_pattern, initial_file_name, audit_record_offset)

    Table 2 Parameter description

    Parameter

    Description

    file_pattern

    Specifies the directory or path and file name for the audit file set to be read.

    initial_file_name

    Specifies the path and name of a specific file in the audit file set to start reading audit records from.

    audit_record_offset

    Specifies a known location with the file specified for the initial_file_name.

    Example:

    select * from msdb.dbo.rds_fn_get_audit_file('D:\ServerAudit\audit\*.sqlaudit', default, default)

    Figure 2 Audit log details

Downloading SQL Audit Logs

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Click in the upper left corner of the page and choose Database > Relational Database Service. The RDS console is displayed.
  4. On the Instance Management page, click the target DB instance.
  5. In the navigation pane on the left, choose Logs. On the System Logs page, click Download.
  6. Locate a log to be downloaded and click Download in the Operation column.

    1. The system automatically loads the downloading preparation tasks. The loading duration is determined by the log file size and network environment.
      • When the log is being prepared for download, the log status is Preparing.
      • When the log is ready for download, the log status is Preparation completed.
      • If the preparation for download fails, the log status is Abnormal.
    2. In the displayed dialog box, click OK to download the log whose status is Preparation completed. If you click Cancel, the system does not download the log.

      The download link is valid for 5 minutes. After the download link expires, a message is displayed indicating that the download link has expired. You can close the window and repeat the procedure 6 to try to download a log again.

Did you find this page helpful?

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel