Skip to content

Alibaba Cloud PolarDB MySQL

Alibaba Cloud PolarDB MySQL Metrics display, including CPU usage, memory hit rate, network traffic, connection count, QPS, TPS, read-only node latency, etc.

Configuration

Install Func

It is recommended to activate TrueWatch Integration - Extensions - DataFlux Func (Automata)

If deploying Func manually, refer to Manual Deployment of Func

Activate Script

Note: Please prepare the required Alibaba Cloud AK in advance (for simplicity, you can directly grant global read-only permission ReadOnlyAccess)

Activate Script for DataFlux Func (Automata)

  1. Log in to the TrueWatch console
  2. Click the 【Integration】 menu, select 【Cloud Account Management】
  3. Click 【Add Cloud Account】, select 【Alibaba Cloud】, and fill in the required information on the interface. If the cloud account information has been configured before, ignore this step
  4. Click 【Test】, if the test is successful, click 【Save】. If the test fails, please check if the relevant configuration information is correct and test again
  5. On the 【Cloud Account Management】 list, you can see the added cloud account. Click the corresponding cloud account to enter the details page
  6. Click the 【Integration】 button on the cloud account details page, find Alibaba Cloud PolarDB MYSQL under the Not Installed list, and click the 【Install】 button to install.

Manually Activate Script

  1. Log in to the Func console, click 【Script Market】, enter the TrueWatch script market, and search for: integration_alibabacloud_polardb

  2. Click 【Install】, then enter the corresponding parameters: Alibaba Cloud AK ID, AK Secret, and account name.

  3. Click 【Deploy Startup Script】, the system will automatically create the Startup script set and configure the corresponding startup script.

  4. After activation, you can see the corresponding automatic trigger configuration in 「Management / Automatic Trigger Configuration」. Click 【Execute】 to execute it immediately without waiting for the scheduled time. After a while, you can view the execution task records and corresponding logs.

We have collected some configurations by default, see the Metrics section for details

Configure Custom Cloud Object Metrics

Verification

  1. In 「Management/Automatic Trigger Configuration」, confirm whether the corresponding task has the corresponding automatic trigger configuration, and check the corresponding task records and logs for any exceptions
  2. In TrueWatch, check if the asset information exists in 「Infrastructure / Custom」
  3. In TrueWatch, check if there is corresponding monitoring data in 「Metrics」

Metrics

After configuring Alibaba Cloud Cloud Monitor, the default Measurement is as follows, more Metrics can be collected through configuration Alibaba Cloud Cloud Monitor Metrics Details

Metric Id Metric Name Dimensions Statistics Unit
cluster_active_sessions Active Connections userId,clusterId,nodeId Average count
cluster_blktag_utilization blktag Utilization userId,clusterId Average %
cluster_connection_utilization Connection Utilization userId,clusterId,nodeId Average,Maximum,Minimum %
cluster_cpu_utilization CPU Utilization userId,clusterId,nodeId Average %
cluster_data_io Storage Engine IO Throughput per Second userId,clusterId,nodeId Average KB
cluster_data_iops Storage Engine IO Count per Second userId,clusterId,nodeId Average countSecond
cluster_direntry_utilization direntry Utilization userId,clusterId Average %
cluster_disk_utilization Disk Utilization userId,clusterId Average %
cluster_imci_datasize IMCI Node Columnar Index Storage userId,clusterId,nodeId Average MB
cluster_imci_exememusage IMCI Executor Memory Usage userId,clusterId,nodeId Average Byte
cluster_imci_stmtsexepersec IMCI SQL Query Count per Second userId,clusterId,nodeId Average count/s
cluster_imci_stmtsinqueue IMCI SQL Count in Scheduling Queue userId,clusterId,nodeId Average count
cluster_imci_tmpfileusedsize IMCI Executor Temporary Table Size userId,clusterId,nodeId Average Byte
cluster_inode_utilization inode Utilization userId,clusterId Average %
cluster_input_traffic Network Input Traffic per Second userId,clusterId,nodeId Average,Maximum,Minimum KByte/s
cluster_iops IO Count per Second userId,clusterId,nodeId Average countSecond
cluster_iops_usage IOPS Utilization userId,clusterId,nodeId Average,Maximum,Minimum %
cluster_mem_hit_ratio Memory Hit Rate userId,clusterId,nodeId Average %
cluster_memory_utilization Memory Utilization userId,clusterId,nodeId Average %
cluster_mps Data Operations per Second userId,clusterId,instanceId Average,Maximum,Minimum countSecond
cluster_output_traffic Network Output Traffic per Second userId,clusterId,nodeId Average,Maximum,Minimum KByte/s
cluster_proxy_cpu_utilization Proxy CPU Utilization userId,clusterId Average,Maximum,Minimum %
cluster_qps Query Count per Second userId,clusterId,nodeId Average count
cluster_redo_write_rate redo Log Write Rate userId,clusterId,nodeId Average Byte/s
cluster_replica_lag Read-Only Node Replication Latency userId,clusterId,instanceId Average,Minimum,Maximum seconds
cluster_slow_queries_ps Slow Query Count per Second userId,clusterId,nodeId Average countS
cluster_total_session Total Current Connections userId,clusterId,nodeId Average,Maximum,Minimum count
cluster_tps Transaction Count per Second userId,clusterId,nodeId Average countS

Object

The collected Alibaba Cloud PolarDB MySQL object data structure can be seen in 「Infrastructure - Custom」

{
  "measurement": "aliyun_polardb",
  "tags": {
    "name"                : "pc-xxxx",
    "RegionId"            : "cn-hangzhou",
    "VpcId"               : "vpc-xxxx",
    "DBNodeNumber"        : "2",
    "PayType"             : "Postpaid",
    "DBType"              : "MySQL",
    "LockMode"            : "Unlock",
    "DBVersion"           : "8.0",
    "DBClusterId"         : "pc-xxxx",
    "DBClusterNetworkType": "VPC",
    "ZoneId"              : "cn-hangzhou-i",
    "Engine"              : "POLARDB",
    "Category"            : "Normal",
    "DBClusterDescription": "pc-xxxx",
    "DBNodeClass"         : "polar.mysql.x4.medium"
  },
  "fields": {
    "DBNodes"   : "{Node list JSON data}",
    "Database"  : "[Database details JSON data]",
    "ExpireTime": "",
    "CreateTime": "2022-06-17T06:07:19Z",
    "message"   : "{Instance JSON data}"
  }
}

Logging

Slow Query Statistics

Prerequisites

Note: The code execution of this script depends on the PolarDB instance object collection. If the custom object collection of PolarDB is not configured, the slow log script cannot collect slow log data

Install Script

On the previous basis, you need to install a corresponding PolarDB Slow Query Statistics Log Collection Script

In 「Management / Script Market」, click and install the corresponding script package:

  • 「TrueWatch Integration (Alibaba Cloud - PolarDB Slow Query Statistics Log Collection)」(ID: integration_alibabacloud_polardb_slowlog)

After the data is synchronized normally, you can view the data in the 「Logs」 of TrueWatch.

The reported data example is as follows:

{
  "measurement": "aliyun_polardb_slowlog",
  "tags": {
    "DBName"  : "PolarDB_MySQL",
    "DBNodeId": "pi-***************"
  },
  "fields": {
    "CreateTime"          : "2023-05-22Z",
    "MaxExecutionTime"    : 60,
    "MaxLockTime"         : 1,
    "ParseMaxRowCount"    : 1,
    "ParseTotalRowCounts" : 2,
    "ReturnMaxRowCount"   : 3,
    "ReturnTotalRowCounts": 1,
    "SQLHASH"             : "U2FsdGVkxxxx",
    "SQLText"             : "select id,name from tb_table",
    "TotalExecutionCounts": 2,
    "TotalExecutionTimes" : 2,
    "TotalLockTimes"      : 1,
    "message"             : "{Log JSON data}"
  }
}

Some parameter descriptions are as follows:

Field Type Description
MaxExecutionTime Long Execution duration (maximum), unit: seconds
TotalExecutionTimes Long Execution duration (total), unit: seconds
TotalLockTimes Long Lock duration (total), unit: seconds
MaxLockTime Long Lock duration (maximum), unit: seconds
ReturnMaxRowCount Long Returned SQL rows (maximum)
ReturnTotalRowCounts Long Returned SQL rows (total)
ParseMaxRowCount Long Parsed SQL rows (maximum)
ParseTotalRowCounts Long Parsed SQL rows (total)
TotalExecutionCounts Long Execution count (total)

Note: The fields in tags, fields may change with subsequent updates

Note: fields.message is a JSON serialized string

Slow Query Details

Prerequisites

Note: The code execution of this script depends on the PolarDB instance object collection. If the custom object collection of PolarDB is not configured, the slow log script cannot collect slow log data

Install Script

On the previous basis, you need to install a corresponding PolarDB Slow Query Details Log Collection Script

In 「Management / Script Market」, click and install the corresponding script package:

  • 「TrueWatch Integration (Alibaba Cloud - PolarDB Slow Query Details Log Collection)」(ID: integration_alibabacloud_polardb_slowlog_record)

After the data is synchronized normally, you can view the data in the 「Logs」 of TrueWatch.

Configure Cloud Database PolarDB Slow Query Details

The reported data example is as follows:

{
  "measurement": "aliyun_polardb_slowlog_record",
  "tags": {
    "DBName"     : "PolarDB_MySQL",
    "DBNodeId"   : "pi-***************",
    "HostAddress": "testdb[testdb] @ [100.**.**.242]"
  },
  "fields": {
    "SQLText"           : "select id,name from tb_table",
    "ExecutionStartTime": "2021-04-07T03:47Z",
    "QueryTimes"        : 20,
    "ReturnRowCounts"   : 0,
    "ParseRowCounts"    : 0,
    "LockTimes"         : 0,
    "QueryTimeMS"       : 100,
    "message"           : "{Log JSON data}"
  }
}

Some parameter descriptions are as follows:

Field Type Description
QueryTimes Long SQL execution duration, unit: seconds
QueryTimesMS Long Query time. Unit: milliseconds
ReturnRowCounts Long Returned rows
ParseRowCounts Long Parsed rows
ExecutionStartTime String SQL start execution time. Format: YYYY-MM-DDThh:mmZ (UTC time)
LockTimes Long SQL lock duration, unit: seconds

Note: The fields in tags, fields may change with subsequent updates

Note: fields.message is a JSON serialized string