Skip to content

Collector "Alibaba Cloud-RDS" Configuration Manual

Before reading this document, please read:

Tip

Before using this collector, you must install the "Integration Core Package" and its accompanying third-party dependencies.

1. Configuration Structure

The configuration structure of this collector is as follows:

Field Type Required Description
regions list Required List of regions to be collected
regions[#] str Required Region ID. For example: 'cn-hangzhou'
See appendix for the complete list

2. Configuration Examples

Specifying Regions

Collect data from Hangzhou and Shanghai regions

collector_configs = {
    'regions': [ 'cn-hangzhou', 'cn-shanghai' ]
}

Configuring Filters (Optional)

This collector script supports custom filters, allowing users to filter target resources based on object attributes. The filter function returns True or False.

  • True: The target resource should be collected.
  • False: The target resource should not be collected.

Supported object attributes for filtering:

Attribute Description
DBInstanceType Instance type
PayType Payment type
Engine Database type
DBInstanceClass Instance family
DBInstanceId Instance ID
ZoneId Availability zone
RegionId Region
LockMode Instance lock mode
DBInstanceDescription Instance description
Category Instance series
EngineVersion Database version
ConnectionMode Instance access mode
DBInstanceNetType Intranet/Internet
DBInstanceStatus Instance status
DBInstanceStorageType Instance storage type
# Example: Enabling a filter to filter based on the InstanceId and RegionId attributes of the object. Configuration format is as follows:

def filter_instance(instance, namespace='aliyun_rds'):
    '''
    Collect metrics for instances with InstanceId i-xxxxxa, i-xxxxxb and RegionId cn-hangzhou
    '''
    instance_id = instance['InstanceId']
    region_id = instance['RegionId']
    if instance_id in ['i-xxxxxa', 'i-xxxxxb'] and region_id in ['cn-hangzhou']:
        return True
    return False

from integration_core__runner import Runner
import integration_alibabacloud_rds__main as main

@DFF.API('AlibabaCloud-RDS Collection', timeout=3600, fixed_crontab="*/5 * * * *")
def run():
    Runner(main.DataCollector(account, collector_configs, filters=[filter_instance])).run()

3. Data Reporting Format

After data is successfully synchronized, you can view the data in the "Infrastructure - Resource Catalog" of TrueWatch.

Example of reported data:

{
  "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" : "{Connection Address JSON Data}",
    "DBInstanceStorage": "100",
    "accounts"         : "{User Permission Information JSON Data}",
    "databases"        : "{Database Information JSON Data}",
    "SSLExpireTime"    : "2022-10-11T08:16:43Z",
    "message"          : "{Instance JSON Data}",
  }
}
Note

The fields in tags and fields may change with subsequent updates.

Tip

The value of tags.name is the instance ID, which serves as the unique identifier.

Tip

fields.message and fields.ConnectionString are JSON serialized strings.

Tip

The units for fields.DiskUsed, fields.BackupSize, fields.LogSize, fields.BackupLogSize, and fields.BackupDataSize are in Bytes. The unit for fields.DBInstanceStorage is in GB.

Tip

field.SSLExpireTime is in UTC time.

X. Appendix

Please refer to the official Alibaba Cloud documentation: