Skip to content

Configuration Manual for the "Alibaba Cloud-CLB" Collector

Before reading this article, please read the following first:

Before using this collector, you must install the 'Integration Core Package' and its associated third-party dependency packages

1. Configuration Structure

The configuration structure of this collector is as follows:

Field Type Required Description
regions list Required List of regions to collect data from
regions[#] str Required Region ID. For example: 'cn-hangzhou'
See the full list in the appendix

2. Configuration Examples

Specifying Regions

Collect data from Hangzhou and Shanghai regions.

Python
1
2
3
collector_configs = {
    'regions': [ 'cn-hangzhou', 'cn-shanghai' ]
}

Configuring Filters (Optional)

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

  • True: The target resource needs to be collected.
  • False: The target resource does not need to be collected.

Supported object attributes for filtering:

Attribute Description
LoadBalancerId Instance ID
RegionId Region ID
SlaveZoneId Backup availability zone ID of the instance
MasterZoneId Main availability zone ID of the instance
Address Service address of the instance
PayType Payment mode
InternetChargeType Public network instance payment method
LoadBalancerName Instance name
LoadBalancerStatus Instance status
NetworkType Network type of private network load balancing instances
AddressType Network type of traditional load balancing instances
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Example: Enable the filter based on the InstanceId and RegionId properties of the object, with the following configuration format:

def filter_instance(instance, namespace='aliyun_slb'):
    '''
    Collect metrics where InstanceId is i-xxxxxa, i-xxxxxb and RegionId is 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 guance_integration__runner import Runner
import guance_aliyun_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 synchronization is successful, you can view the data in the "Infrastructure - Resource Catalog" section of {{( brand_name }}}.

An example of the reported data is as follows:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  "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": "{JSON data of listener ports}",
    "ServerHealthStatus"      : "{JSON data of instance health status}",
    "ServerCertificates"      : "{JSON data of certificate information}",
    "Bandwidth"               : "5120",
    "EndTimeStamp"            : "32493801600000",
    "Tags"                    : "[Tags set in the cloud console]",
    "message"                 : "{JSON data of the instance}",
  }
}

Fields in tags and fields may change with subsequent updates

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

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

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

fields.AutoReleaseTime, fields.EndTimeStamp are timestamps (unit: seconds)

X. Appendix

Please refer to the official Alibaba Cloud documentation: