Skip to content

Alibaba Cloud RDS MySQL

Alibaba Cloud RDS MySQL Metrics Display, including CPU usage, memory usage, IOPS, network bandwidth, InnoDB, TPS, QPS, etc.

Configuration

Install Func

It is recommended to enable Guance Integration - Extension - Managed Func

If you deploy Func by yourself, please refer to Self-deployed Func

Enable Script

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

Managed Version Enable Script

  1. Log in to Guance Console
  2. Click on the 【Manage】 menu and select 【Cloud Account Management】
  3. Click 【Add Cloud Account】, select 【Alibaba Cloud】, fill in the information required on the interface; if cloud account information has been configured before, skip this step
  4. Click 【Test】, after the test succeeds click 【Save】. If the test fails, check whether the related configuration information is correct and retest.
  5. Click on the 【Cloud Account Management】 list to see the added cloud account, click on the corresponding cloud account, enter the details page
  6. Click the 【Integration】 button on the cloud account detail page, find Alibaba Cloud RDS MySQL under the Not Installed list, click the 【Install】 button, a popup installation interface will appear for installation.

Manual Enable Script

  1. Log in to the Func Console, click 【Script Market】, enter the official script market, search:guance_aliyun_rds

  2. After clicking 【Install】, input the corresponding parameters: Alibaba Cloud AK ID, AK Secret, and account name.

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

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

We default collect some configurations, for more details see the metrics section.

Customize Cloud Object Metrics

Verification

  1. In 「Management / Automatic Trigger Configuration」, confirm whether the corresponding task has an automatic trigger configuration, while you can check the corresponding task records and logs to ensure there are no abnormalities.
  2. In Guance, 「Infrastructure / Custom」, check if asset information exists.
  3. In Guance, 「Metrics」 check if corresponding monitoring data exists.

Metrics

After configuring Alibaba Cloud - Cloud Monitoring, the default measurement set is as follows. You can collect more metrics via configuration Alibaba Cloud Cloud Monitoring Metrics Details

Metric Id Metric Name Dimensions Statistics Unit
ConnectionUsage Connection Usage Rate userId,instanceId Average,Minimum,Maximum %
CpuUsage CPU Usage Rate userId,instanceId Average,Minimum,Maximum %
DiskUsage Disk Usage Rate userId,instanceId Average,Minimum,Maximum %
IOPSUsage IOPS Usage Rate userId,instanceId Average,Minimum,Maximum %
MemoryUsage Memory Usage Rate userId,instanceId Average,Minimum,Maximum %
MySQL_ComDelete MySQL Deletes per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_ComInsert MySQL Inserts per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_ComInsertSelect MySQL InsertSelects per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_ComReplace MySQL Replaces per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_ComReplaceSelect MySQL ReplaceSelects per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_ComSelect MySQL Selects per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_ComUpdate MySQL Updates per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_DataDiskSize MySQL Data Disk Usage userId,instanceId Average,Maximum,Minimum Megabytes
MySQL_IbufDirtyRatio MySQL_BP Dirty Page Percentage userId,instanceId Average,Maximum,Minimum %
MySQL_IbufReadHit MySQL_BP Read Hit Rate userId,instanceId Average,Maximum,Minimum %
MySQL_IbufRequestR MySQL Logical Reads per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_IbufRequestW MySQL Logical Writes per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_IbufUseRatio MySQL_BP Utilization Rate userId,instanceId Average,Maximum,Minimum %
MySQL_InnoDBDataRead MySQL_InnoDB Data Read per Second userId,instanceId Average,Maximum,Minimum Kbyte
MySQL_InnoDBDataWritten MySQL_InnoDB Data Written per Second userId,instanceId Average,Maximum,Minimum Kbyte
MySQL_InnoDBLogFsync MySQL_InnoDB Log fsyncs per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_InnoDBLogWriteRequests MySQL_InnoDB Log Write Requests per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_InnoDBLogWrites MySQL_InnoDB Log Physical Writes per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_InnoDBRowDelete MySQL_InnoDB Rows Deleted per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_InnoDBRowInsert MySQL_InnoDB Rows Inserted per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_InnoDBRowRead MySQL_InnoDB Rows Read per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_InnoDBRowUpdate MySQL_InnoDB Rows Updated per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_InstanceDiskSize MySQL Instance Disk Usage userId,instanceId Average,Maximum,Minimum Megabytes
MySQL_LogDiskSize MySQL Log Disk Usage userId,instanceId Average,Maximum,Minimum Megabytes
MySQL_NetworkInNew MySQL Network Inbound Bandwidth userId,instanceId Average,Minimum,Maximum bits/s
MySQL_NetworkOutNew MySQL Network Outbound Bandwidth userId,instanceId Average,Minimum,Maximum bits/s
MySQL_OtherDiskSize MySQL Other Disk Usage userId,instanceId Average,Maximum,Minimum Megabytes
MySQL_QPS MySQL Queries per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_SlowQueries MySQL Slow Queries per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_TPS MySQL Transactions per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_TempDiskTableCreates MySQL Temporary Tables Created per Second userId,instanceId Average,Maximum,Minimum countSecond
MySQL_ThreadsConnected MySQL Threads Connected userId,instanceId Average,Maximum,Minimum count
MySQL_ThreadsRunning MySQL Active Threads userId,instanceId Average,Maximum,Minimum count

Objects

Collected Alibaba Cloud SLB object data structure, which can be seen from 「Infrastructure - Custom」.

{
  "measurement": "aliyun_rds",
  "tags": {
    "name"                 : "rm-xxxxx",
    "DBInstanceType"       : "Primary",
    "PayType"              : "Prepaid",
    "Engine"               : "MySQL",
    "DBInstanceClass"      : "rds.mysql.s2.large",
    "DBInstanceId"         : "rm-xxxxx",
    "ZoneId"               : "cn-shanghai-h",
    "RegionId"             : "cn-shanghai",
    "DBInstanceDescription": "Business System",
    "LockMode"             : "Unlock",
    "Category"             : "Basic",
    "ConnectionMode"       : "Standard",
    "DBInstanceNetType"    : "Intranet",
    "DBInstanceStorageType": "local_ssd",
  },
  "fields": {
    "CreationTime"     : "2022-12-13T16:00:00Z",
    "ExpireTime"       : "2022-12-13T16:00:00Z",
    "DiskUsed"         : "10000",
    "BackupSize"       : "10000",
    "LogSize"          : "10000",
    "BackupLogSize"    : "10000",
    "BackupDataSize"   : "10000",
    "ConnectionString" : "{JSON connection address data}",
    "DBInstanceStorage": "100",
    "accounts"         : "{JSON user permission information data}",
    "databases"        : "{JSON database information data}",
    "SSLExpireTime"    : "2022-10-11T08:16:43Z",
    "message"          : "{JSON instance data}",
  }
}

Logs

Slow Query Statistics

Slow Query Statistics Prerequisites

Hint 1: The code execution of this script depends on the collection of RDS instance objects. If RDS custom object collection is not configured, the slow log script cannot collect slow log data. Hint 2: Due to the 6~8 hour delay in returning statistics from Alibaba Cloud, there may be delays in the data collected by the collector. For detailed reference, see Alibaba Cloud documentation: Cloud Database RDS Query Slow Log Statistics. Hint 3: This collector supports all versions of MySQL (excluding the Basic Edition of MySQL 5.7), SQL Server 2008 R2, MariaDB 10.3 type databases. To collect other types of databases, use the Alibaba Cloud-RDS Slow Query Detail collector.

Slow Query Statistics Installation Script

Based on previous steps, install another script for RDS Slow Query Statistics Log Collection

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

  • 「Guance Integration (Alibaba Cloud - RDS Slow Query Statistics Log Collection)」(ID: guance_aliyun_rds_slowlog)

After data synchronizes normally, you can view the data in the 「Logs」 section of Guance.

Example reported data:

{
  "measurement": "aliyun_rds_slowlog",
  "tags": {
    "name"                 : "rm-xxxxx",
    "DBName"               : "cloudcare_core",
    "DBInstanceId"         : "rm-bp1xxxxxxxxxx",
    "RegionId"             : "cn-hangzhou",
    "DBInstanceType"       : "Primary",
    "PayType"              : "Prepaid",
    "Engine"               : "MySQL",
    "DBInstanceClass"      : "rds.mysql.s2.large",
    "ZoneId"               : "cn-shanghai-h",
    "DBInstanceDescription": "Business System"
  },
  "fields": {
    "SQLHASH"                      : "436f9dd030e0a87920bbcd818b34f271",
    "SQLText"                      : "{SQL statement}",
    "CreateTime"                   : "2022-06-05Z",
    "SQLServerTotalExecutionTimes" : 0,
    "MaxExecutionTime"             : 1,
    "MaxLockTime"                  : 0,
    "AvgExecutionTime"             : 0,
    "MySQLTotalExecutionTimes"     : 0,
    "SQLServerTotalExecutionTimes" : 1,
    "SQLServerTotalExecutionCounts": 0,
    "MySQLTotalExecutionCounts"    : 0,
    "SQLServerAvgExecutionTime"    : 0,
    "message"                      : "{Log JSON data}"
  }
}

Explanation of some parameters:

Field Type Description
SQLServerTotalExecutionTimes int SQL Server Execution Time (total, milliseconds)
AvgExecutionTime int Execution Time (average) unit: seconds
SQLServerAvgExecutionTime int Execution Time (average) unit: seconds
MySQLTotalExecutionTimes int MySQL Execution Time (total) unit: seconds
SQLServerTotalExecutionTimes int SQL Server Execution Time (total) unit: milliseconds
SQLServerTotalExecutionCounts int SQL Server Execution Count (total)
MySQLTotalExecutionCounts int MySQL Execution Count (total)

Note: Fields such as AvgExecutionTime, SQLServerAvgExecutionTime, SQLServerTotalExecutionTimes, etc., are only supported by SQL Server instances. Note: Fields in tags and fields may change with subsequent updates.

Slow Query Details

Slow Query Details Prerequisites

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

Slow Query Details Installation Script

Based on previous steps, install another script for RDS Slow Query Detail Log Collection

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

  • 「Guance Integration (Alibaba Cloud - RDS Slow Query Detail Log Collection)」(ID: guance_aliyun_rds_slowlog_record)

After data synchronizes normally, you can view the data in the 「Logs」 section of Guance.

Configuration Cloud Database RDS Slow Query Details

Example reported data:

{
  "measurement": "aliyun_rds_slowlog",
  "tags": {
    "name"                 : "rm-xxxxx",
    "DBName"               : "cloudcare_core",
    "DBInstanceId"         : "rm-bp1xxxxxxxxxx",
    "RegionId"             : "cn-hangzhou",
    "DBInstanceType"       : "Primary",
    "PayType"              : "Prepaid",
    "Engine"               : "MySQL",
    "DBInstanceClass"      : "rds.mysql.s2.large",
    "ZoneId"               : "cn-shanghai-h",
    "DBInstanceDescription": "Business System",
    "HostAddress"          : "xxxx",
    "UserName"             : "xxxx",
    "ClientHostName"       : "xxxx",
    "ApplicationName"      : "xxxx",

  },
  "fields": {
    "SQLHASH"                      : "436f9dd030e0a87920bbcd818b34f271",
    "SQLText"                      : "{SQL statement}",
    "QueryTimes"                   : 0,
    "QueryTimesMS"                 : 0,
    "ReturnRowCounts"              : 0,
    "ParseRowCounts"               : 0,
    "ExecutionStartTime"           : "2022-02-02T12:00:00Z",
    "CpuTime"                      : 1,
    "RowsAffectedCount"            : 0,
    "LastRowsAffectedCount"        : 0,
    "message"                      : "{Log JSON data}"
  }
}

Explanation of some parameters:

Field Type Description
QueryTimes int Execution Duration. Unit: second (s)
QueryTimesMS int Execution Duration. Unit: millisecond (ms)
ReturnRowCounts int Returned Row Count
ParseRowCounts int Parsed Row Count
ExecutionStartTime str Execution Start Time
CpuTime int CPU Processing Time
RowsAffectedCount int Affected Row Count
LastRowsAffectedCount int Last Statement Affected Row Count

Note: Fields such as CpuTime, RowsAffectedCount, LastRowsAffectedCount, etc., are only supported by SQL Server instances. Note: Fields in tags and fields may change with subsequent updates. Hint: fields.message is a JSON serialized string

Feedback

Is this page helpful? ×