Skip to content

Collector "Alibaba Cloud-CLB" 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. 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
LoadBalancerId Instance ID
RegionId Region ID
SlaveZoneId Secondary zone ID of the instance
MasterZoneId Primary zone ID of the instance
Address Service address of the instance
PayType Payment mode
InternetChargeType Payment method for public network instances
LoadBalancerName Instance name
LoadBalancerStatus Instance status
NetworkType Network type of private load balancer instances
AddressType Network type of classic load balancer instances
# Example: Enable filter to filter based on InstanceId and RegionId attributes, configuration format as follows:

def filter_instance(instance, namespace='aliyun_slb'):
    '''
    Collect metrics for instances with InstanceId as i-xxxxxa, i-xxxxxb and RegionId as 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_slb__main as main

@DFF.API('AlibabaCloud-SLB Collection', timeout=3600, fixed_crontab='*/15 * * * *')
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_slb",
  "tags": {
    "name"              : "lb.xxxxxxxx",
    "LoadBalancerId"    : "lb.xxxxxxxxx",
    "RegionId"          : "cn-shanghai",
    "SlaveZoneId"       : "cn-shanghai-i",
    "MasterZoneId"      : "cn-shanghai",
    "Address"           : "172.xxx.xxx.xxx",
    "PayType"           : "PayOnDemand",
    "InternetChargeType": "paybytraffic",
    "LoadBalancerName"  : "Business System",
    "LoadBalancerStatus": "active",
    "AutoReleaseTime"   : "1513947075000",
    "RenewalStatus"     : "AutoRenewal",
    "AddressType"       : "Internet",
    "NetworkType"       : "vpc",
},
  "fields": {
    "CreateTime"              : "2020-11-18T08:47:11Z",
    "ListenerPortsAndProtocol": "{Listener Port JSON Data}",
    "ServerHealthStatus"      : "{Instance Health Status JSON Data}",
    "ServerCertificates"      : "{Certificate Information JSON Data}",
    "Bandwidth"               : "5120",
    "EndTimeStamp"            : "32493801600000",
    "Tags"                    : "[Tags set in the Cloud Console]",
    "message"                 : "{Instance JSON Data}",
  }
}
Note

Fields in tags and fields may change with subsequent updates.

Tip

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

Tip

fields.message, fields.ListenerPortsAndProtocol, and fields.Tags are all JSON serialized strings.

Tip

fields.ServerHealthStatus represents the health status of the instances under the SLB.

Tip

fields.AutoReleaseTime and fields.EndTimeStamp are timestamps (in seconds).

X. Appendix

Please refer to the official Alibaba Cloud documentation: