PolarDB-X provides the SQL audit and analysis features that are developed based on Log Service and provides reports of SQL execution monitoring, SQL performance monitoring, and security monitoring. You can view the statistical information about SQL queries, SQL performance metrics, and potential risks of your PolarDB-X databases.
Prerequisites
The SQL audit and analysis features are enabled for your PolarDB-X instance. For more information, see Enable SQL audit and analysis.
Note
The audit logs of PolarDB-X databases that are deployed in the same region are stored in the same Logstore in Log Service. By default, the __topic__:polardbx_sqlaudit and instance_id:xxxxxxxxx
conditions are used. When you search for log entries based on these conditions, all log entries that are returned are collected from the PolarDB-X instance.
View log reports
Log on to the PolarDB for Xscale console.
In the top navigation bar, select the region where the target instance is located.
On the Instances page, click the PolarDB-X 2.0 tab.
Find the target instance and click its ID.
In the left-side navigation pane, choose .
On the SQL Audit and Analysis page, click the Log Reports tab. On the page that appears, click the tabs to view the statistical information about SQL queries, performance metrics, and potential risks.
Operations: On this tab, you can view the statistical information about SQL queries that is collected from all databases in the PolarDB-X instance. You can view the metrics, distribution, and trends of SQL queries.
Category
Chart
Type
Default time range
Description
Basic metrics
PV (SQL queries)
Single value
1 hour (Relative)
The number of SQL queries that were executed within a specified period of time.
UV (By username and IP address)
Single value
1 hour (Relative)
The number of clients that sent requests within a specified period of time. Each client can be identified by username and IP address.
Number of malicious IP addresses
Single value
1 hour (Relative)
The number of malicious IP addresses that are collected within a specified period of time.
NoteFor more information about malicious IP addresses, see Security check functions.
Number of failed queries
Single value
1 hour (Relative)
The number of failed queries that were executed within a specified period of time.
Number of related tables
Single value
1 hour (Relative)
The total number of tables on which SQL statements were executed within a specified period of time.
Operation metrics
Total inserted rows
Single value
1 hour (Relative)
The total number of rows into which data was inserted within a specified period of time.
Total updated rows
Single value
1 hour (Relative)
The total number of rows in which data was updated within a specified period of time.
Total deleted rows
Single value
1 hour (Relative)
The total number of rows from which data was deleted within a specified period of time.
Total queried rows
Single value
1 hour (Relative)
The total number of data rows that were returned to clients within a specified period of time.
Non-table-based SQL types
Single value
1 hour (Relative)
The types of SQL statements that were not executed on tables, such as
SHOW VARIABLES LIKE
.Trends
Trend of SQL queries
Column chart
1 hour (Relative)
The trend of SQL queries and the trend of SQL failures that occurred within a specified period of time.
Related tables
Flow chart
1 hour (Relative)
The distribution of tables on which SQL statements were executed within a specified period of time.
SQL types
Flow chart
1 hour (Relative)
The distribution of each type of SQL statements that were executed within a specified period of time. The results are displayed based on the points in time when the SQL statements were executed.
Distribution
Distribution of users
Pie chart
1 hour (Relative)
The distribution of users who sent SQL requests within a specified period of time.
SQL type distribution
Pie chart
1 hour (Relative)
The ratio of each type of SQL statement that was executed within a specified period of time.
Top 50 tables on which the largest number of operations are performed
Table
1 hour (Relative)
The top 50 tables on which the largest number of operations were performed. The displayed information includes table names and the number of read, delete, update, and insert operations.
Distribution of clients (Global)
Map
1 hour (Relative)
The distribution of IP addresses from which SQL requests were sent. The statistical information is displayed on the world map.
Distribution of clients (China)
Map
1 hour (Relative)
The distribution of IP addresses from which SQL requests were sent. The statistical information is displayed on the map of China.
Performance: On this tab, you can view specific performance metrics that are collected from all databases in the PolarDB-X instance. You can view information such as the maximum number of SQL queries per second, the average execution duration of SQL statements, and the sources and distribution of slow SQL statements. SQL statements that require more than 1 second to execute are slow SQL statements.
Category
Chart
Type
Default time range
Description
Basic metrics
Peak SQL queries
Single value
1 hour (Relative)
The maximum number of SQL statements that were executed per second.
Peak queries
Single value
1 hour (Relative)
The maximum number of data rows that were returned per second.
Peak inserts
Single value
1 hour (Relative)
The maximum number of rows into which data was inserted per second.
Peak updates
Single value
1 hour (Relative)
The maximum number of rows in which data was updated per second.
Peak deletes
Single value
1 hour (Relative)
The maximum number of rows from which data was deleted per second.
Average execution duration
Average execution duration
Single value
1 hour (Relative)
The average period of time that the system took to execute an SQL statement.
SELECT statements
Single value
1 hour (Relative)
The average number of SELECT statements that were executed per second.
INSERT statements
Single value
1 hour (Relative)
The average number of INSERT statements that were executed per second.
UPDATE statements
Single value
1 hour (Relative)
The average number of UPDATE statements that were executed per second.
DELETE statements
Single value
1 hour (Relative)
The average number of DELETE statements that were executed per second.
Distribution of SQL queries
Trends of queries and updates
Line chart
1 hour (Relative)
The number of rows on which SELECT statements and UPDATE statements were executed. The statistical information is displayed by time.
Distribution of SQL queries by time
Pie chart
1 hour (Relative)
The distribution of SQL queries. The statistical information is displayed based on the points in time when the SQL statements were executed.
Distribution of slow SQL statements
Distribution of slow SQL statements related tables
Pie chart
1 hour (Relative)
The distribution of tables on which slow SQL statements were executed.
Distribution of slow query request senders
Pie chart
1 hour (Relative)
The distribution of users who sent slow query requests.
Distribution of slow SQL query types
Pie chart
1 hour (Relative)
The distribution of each type of slow SQL statements.
Top 50 slow SQL statements
Table
1 hour (Relative)
The information about the top 50 slow SQL queries. The following information about each SQL query is displayed:
The local time when the system started to execute the SQL statement
The information about the client, such as the IP address, region, and network
The period of time that the system took to execute the SQL statement
The ID of the PolarDB-X instance on which the SQL statement was executed
The database on which the SQL statement was executed
The table on which the SQL statement was executed
The user who performed the operation
The number of rows on which the SQL statement was executed
The type of the SQL statement that was executed
The SQL statement that was executed
SQL templates that consumed large amounts of resources
Top 20 SQL templates that consumed the longest period of time to execute
Table
1 hour (Relative)
The information about the top 20 SQL templates that consumed the largest amounts of resources. The following information about each SQL template is displayed:
The ID of the SQL template
The ratio of the period of time that the system took to execute SQL statements that are generated based on the template to the total period of time that the system took to execute all SQL statements
The number of SQL statements in which the SQL template is used
The average execution duration of SQL statements that were generated based on the template (Unit: ms)
The average number of rows on which SQL statements that were generated based on the template were executed
A sample SQL statement that was generated based on the template
Transactional SQL
Top 20 transactions that were executed on the largest number of rows
Table
1 hour (Relative)
The information about the top 20 transactions that were executed on the largest number of rows. The following information is displayed:
The ID of the transaction
The number of rows on which the transaction was executed
Top 20 transactions that the system took the longest period of time to execute
Table
1 hour (Relative)
The information about the top 20 transactions that the system took the longest period of time to execute. The following information is displayed:
The ID of the transaction
The period of time that the system took to execute the transaction (Unit: ms)
Security: On this tab, you can view the statistical information about the failed SQL queries and malicious SQL statements that were executed on all databases in the PolarDB-X instance. Malicious SQL statements include DROP and TRUNCATE statements and statements that are used to delete or update more than 100 rows of data. The details, distribution, and trends of these delete and update statements are also displayed.
Category
Chart
Type
Default time range
Description
Security metrics
Number of failures
Single value
1 hour (Relative)
The number of failed SQL queries.
Batch delete events
Single value
1 hour (Relative)
The number of SQL statements that were executed to delete data from a large number of rows.
Batch update events
Single value
1 hour (Relative)
The number of SQL statements that were executed to update the data that is stored in a large number of rows.
Number of malicious SQL queries
Single value
1 hour (Relative)
The number of SQL queries that can affect your business in a negative manner.
Number of malicious IP addresses
Single value
1 hour (Relative)
The number of IP addresses from which SQL requests that can affect your business in a negative manner were sent.
NoteFor more information about malicious IP addresses, see Security check functions.
Distribution of failed SQL queries
Distribution of failed SQL queries by type
Area chart
1 hour (Relative)
The distribution of failed SQL queries. The statistical information is displayed based on the types to which the SQL statements belong.
Distribution of clients that sent the failed queries
Map
1 hour (Relative)
The distribution of clients that sent the failed queries. The statistical information is displayed on the map of China.
Clients that sent the largest number of failed SQL queries
Table
1 hour (Relative)
The clients that sent the largest number of failed queries. The following information is displayed:
The information about the client, such as the IP address, region, and network
The number of failures
Operations that frequently fail, such as query, insert, update, delete, or other operations
Sample error
Malicious SQL queries
Malicious SQL queries
Table
1 hour (Relative)
The SQL queries that can affect your business in a negative manner. The following information is displayed:
The local time when the system started to execute the SQL statement
The information about the client, such as the IP address, region, and network
SQL
The ID of PolarDB-X instance on which the SQL statement was executed
The database on which the SQL statement was executed
The table on which the SQL statement was executed
The user who performed the operation
Transactions that use batch operations
Top 50 batch delete events
Table
1 hour (Relative)
The SQL statements that were executed to delete data from more than 100 rows. The following details of each SQL statement are displayed:
The first point in time when the SQL statement was executed
The most recent point in time when the SQL statement was executed
The ID of PolarDB-X instance on which the SQL statement was executed
The database on which the SQL statement was executed
The table on which the SQL statement was executed
The number of executions of the SQL statement
The average number of rows from which data was deleted
The average execution duration (Unit: s)
SQL
Top 50 batch update events
Table
1 hour (Relative)
The SQL statements that were executed to update the data that is stored in a large number of rows. The following details of each SQL statement is displayed:
The first point in time when the SQL statement was executed
The most recent point in time when the SQL statement was executed
The ID of PolarDB-X instance on which the SQL statement was executed
The database on which the SQL statement was executed
The table on which the SQL statement was executed
The number of executions of the SQL statement
The average number of rows in which data was updated
The average execution duration (Unit: s)
SQL
Change the time range for data collection
Each chart that is displayed on the Log Report tab is generated based on statistics that are collected within a specified time range. By default, the time range is set to the previous hour. You can change the time range for a single chart or all charts on the Operations tab, the Performance tab, or the Security tab.
Change the time range for data collection for all charts on a tab
In the upper-right corner of the tab, click Time Range. In the panel that appears, click the time range that you want to specify for all charts on the tab.
Change the time range for data collection for a chart on a tab
Move the pointer over the icon in the upper right corner of the chart and click Select Time Range. In the panel that appears, click the time range that you want to specify for the chart.