Audit logs
Lindorm audit logs record SQL operations. You can use audit logs to view all operations performed during a specified period, filter records by different dimensions, and analyze the logs.
Prerequisites
Audit logging is enabled for your Lindorm instance. For more information, see Audit logs.
The compute engine is version 3.4.25 or later.
Audit log types
Lindorm audit logs record the following operations:
DDL operations, such as
CREATE DATABASE,CREATE TABLE,ALTER TABLE, andDROP TABLE.DQL operations, such as
SELECT.DML operations, such as
DELETE,INSERT, andUPDATE.Spark JAR jobs, including the jobId, JAR package, mainClass, job status, and resource consumption.
Lindorm audit logs are retained for 15 days by default. Logs are deleted when their retention period expires.
To change the audit log retention period, see How to delete logs.
View audit logs
Log on to the Lindorm console.
In the upper-left corner of the page, select the region where the instance is deployed.
On the Instances page, click the ID of the target instance or click View Instance Details in the Actions column for the instance.
In the left-side navigation pane, click Compute Engine.
Click the Audit Logs tab to query and analyze audit logs. For instructions, see Query and analysis quick start.
Audit log fields
Compute engine audit logs contain the following fields:
Field name | Description |
content | The request content, such as the SQL statement. |
computeGroup | The resource group name. |
timestamp | The response time of the request, in milliseconds (ms). |
instance_id | The Lindorm instance ID. |
jobId | The job ID. |
jobName | The job name. |
userName | The name of the user who initiated the request. |
Use the SLS assistant
Select Use Copilot in the query bar to open the STAROps-SLS Assistant pane on the right. Enter what you want to analyze to obtain the corresponding results and charts. For example, enter:
Retrieve resourceUsed for all jobs from the past 7 days and sort the values in descending order.The SLS assistant automatically queries the data. You can export the results.
SQL best practices
You can also query logs by using SQL. The following examples illustrate common queries.
Find the users who performed operations on the db.table table:
* | SELECT content, userName, count(*) AS cnt, min(__time__) AS first_time, max(__time__) AS last_time FROM log WHERE content LIKE '%db.table%' GROUP BY content, userName ORDER BY first_time LIMIT 100Identify the users who submitted SQL statements such as INSERT, UPDATE, DROP, and DELETE, and count their operations:
* | SELECT userName, op_type, count(*) AS cnt FROM ( SELECT userName, regexp_extract(content, '(DELETE|DROP|UPDATE|INSERT)', 1) AS op_type FROM log ) WHERE op_type IS NOT NULL GROUP BY userName, op_type ORDER BY cnt DESC LIMIT 50Retrieve and sort the compute unit hours (CUH) consumed by jobs in a resource group during a specified period:
content: resourceUsed | SELECT from_unixtime(__time__) AS log_time, instance_id, jobName, jobId, userName, content, try_cast(regexp_extract(content, 'resourceUsed=([0-9.]+)', 1) AS double) AS resourceUsed FROM log ORDER BY resourceUsed DESC LIMIT 100