Audit logs record detailed information about database activities. By viewing audit logs, you can track potential malicious activities or unauthorized access to a database, investigate the causes of security events, and meet compliance requirements.
Prerequisites
Enable data audit for the supported data assets that you want to audit. For more information, see Enable data audit.
Logs
Log storage location
After you enable data audit, Data Security Center (DSC) collects and stores logs in a Simple Log Service (SLS) Logstore:
-
Project
The project name is in the
sddp-${uid}-${regionId}format. In this format,${uid}is the ID of your Alibaba Cloud account and${regionId}is the ID of the region where the database is located. -
Logstore
Category
Database type
Logstore
Relational database
RDS
rds_log
PolarDB
dsc_polardb_log
PolarDB-X
dsc_drds_log
OceanBase
dsc_oceanbase_log
Non-relational database
Redis
dsc_redis_log
MongoDB
dsc_mongodb_log
Unstructured database
OSS
dsc_oss_log
Big data
Tablestore
dsc_ots_log
MaxCompute
dsc_odps_tunnel_log
ADB-MYSQL
dsc_ads_log
ADB-PG
dsc_gpdb_log
self-managed database
MySQL
dsc_self_built_db_log
SQL Server
PostgreSQL
Oracle
Common fields
|
Field |
Description |
|
client_ip |
The IP address of the client. |
|
clusterId |
The cluster ID. |
|
collector_type |
The log collection type. |
|
db |
The database name. |
|
db_type |
The database engine type. |
|
effect_row |
The number of affected rows. |
|
execute_time |
The execution time. |
|
fail |
The execution result. |
|
hash |
The hash value. |
|
instance_id |
The instance ID. |
|
latency |
The execution duration in microseconds. |
|
node_name |
The node name. |
|
operate_type |
The operation type. |
|
origin_time |
The original execution time of the SQL statement. |
|
region_id |
The region ID. |
|
return_rows |
The number of rows returned in the result set. |
|
sql |
The SQL statement. |
|
thread_id |
The thread ID. |
|
uid |
The user ID. |
|
update_rows |
The number of updated rows. |
|
user |
The logon username. |
View data audit logs (new version)
Log on to the Data Security Center console.
In the navigation pane on the left, select Log Analysis.
-
On the Log Analysis page, click New Version in the upper-right corner.
If Switch to Old Version is displayed in the upper-right corner, skip this step.
-
In the left-side navigation bar of the Log Analysis page, click a product type to view its log storage location.
The available product types include RDS, PolarDB, PolarDB-X, Redis, MongoDB, OceanBase, and self-managed database. The number of connected instances for each type is displayed in parentheses.
-
In the log area on the right, you can search for and view the operation logs of the target database or bucket by using parameters such as region, instance, account, and operation type.
You can also enter query and analysis statements to analyze the logs of the target data asset based on the query syntax and analysis syntax. For more information, see Quick start for query and analysis.
Query and analysis examples
-
View the access details for a table in a database of an RDS instance. The details include the access user, operation type, and operation result.
* and instance_id: rm-bp1******5u5w and db: s****p and table_name : sys_d*****itThe query result displays the details of an audit log entry. Key fields include db_type (MySQL), operate_type (Select), sql (
SELECT * FROM), latency (428), fail (0), and ret_code (0), and other fields such as user, table_name, and thread_id. You can use these fields to identify the access user, operation type, and operation result.sys_data_limitLIMIT 20 -
View the distribution of IP addresses accessing a data table in an RDS instance.
* and instance_id: rm-bp1*****5u5w and db: s****p and table_name : sys_d*****it | select user,client_ip,count(*) group by user,client_ipAfter you enter the query statement, click Query/Analyze, and then click the Graph tab to view the aggregated results, including user, client_ip, and the corresponding number of accesses.
-
Calculate statistics on the outbound traffic over the internet for all files in a directory of a specified bucket.
* and __topic__ : oss_access_log and bucket: examplebucket and host : "examplebucket.oss-cn-hangzhou.aliyuncs.com" not sync_request : cdn | select SUM(content_length_out) AS total_traffic_out_byte WHERE url_decode(object) LIKE 'exampledir/%'Click the Graph tab to view the query result. The returned field
total_traffic_out_bytehas a value of 11749, which indicates that the outbound traffic from the specified directory is 11,749 bytes.
-
Download logs
DSC collects and stores logs in Simple Log Service (SLS). The DSC console integrates the log download feature of the SLS console. This allows you to download logs or query and analysis results to your local computer. The download procedure in the DSC console is similar to that in the SLS console. For more information, see Download logs by using the SLS console.
Data audit logs (old version)
Related documents
-
DSC stores the audit logs that you can query online. You can view the current storage usage and manage the storage rules for online and archived logs. For more information, see Manage log storage.
-
By default, DSC provides built-in audit rules for data assets. These include database audit rules, OSS audit rules, and MaxCompute audit rules. You can also create custom audit rules. After you enable audit alert rules, you can use audit logs to detect risks to data assets, such as abnormal operations, data leaks, vulnerabilities, and SQL injection attacks. For more information, see Configure and enable audit alert rules.
-
After you enable an audit alert rule, DSC reports behaviors that trigger the rule as audit alerts in DSC. You can analyze and handle the related risks based on the alert information and audit logs. For more information, see View and handle audit alerts.
