Skip to content

Collector Configuration Manual for "Alibaba Cloud-ECS"

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. Example: 'cn-hangzhou'
Refer to the appendix for the full table

2. Configuration Examples

Specify Regions

Collect data from Hangzhou and Shanghai regions

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

Configure 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: Target resource needs to be collected.
  • False: Target resource does not need to be collected.

Supported object attributes for filtering:

Attribute Description
name Instance ID
HostName Instance ID
InstanceName Instance Hostname
InstanceId Instance ID
ZoneId Availability Zone ID
InstanceChargeType Instance billing method. Possible values:
PrePaid: Annual/Monthly.
PostPaid: Pay-as-you-go.
InternetChargeType Billing method for elastic public IP. Possible values:
PayByBandwidth: Billing by bandwidth.
PayByTraffic: Billing by traffic.
OSType Instance operating system
PublicIpAddress_IpAddress List of public IPs of the instance
InstanceType Instance specification
InstanceTypeFamily Instance specification family
Status Instance status
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Example: Enable filters, filter based on the InstanceId and name properties of the object, configuration format is as follows:
def filter_instance(instance):
    '''
    Collect instances with instance_id as xxxxx or instance_name as xxxxx
    '''
    # return True
    instance_id = instance['InstanceId']
    instance_name = instance['name']
    if instance_id in ['xxxxx'] or instance_name in ['xxxxx']:
        return True
    return False


###### Do not modify the following contents #####
from guance_integration__runner import Runner
import guance_aliyun_ecs__main as main


@DFF.API('AlibabaCloud-ECS 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 }}}.

Example of reported data:

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
30
31
32
33
34
35
{
  "measurement": "aliyun_ecs",
  "tags": {
    "name"                     : "i-xxxxx",
    "HostName"                 : "xxxxx",
    "InstanceName"             : "xxxxx",
    "InstanceId"               : "i-xxxxx",
    "RegionId"                 : "cn-hangzhou",
    "ZoneId"                   : "cn-hangzhou-a",
    "InstanceChargeType"       : "PrePaid",
    "InternetChargeType"       : "PayByTraffic",
    "OSType"                   : "linux",
    "PublicIpAddress_IpAddress": "['xxxx',]",
    "InstanceType"             : "ecs.c6.xlarge",
    "InstanceTypeFamily"       : "ecs.c6",
    "Status"                   : "Running"
  },
  "fields": {
    "CreationTime"           : "2022-01-01T00:00Z",
    "StartTime"              : "2022-01-02T00:00Z",
    "ExpiredTime"            : "2023-01-01T00:00Z",
    "disks"                  : "[ {JSON data related to disks}, ... ]",
    "network_interfaces"     : "[ {JSON data related to network interfaces}, ... ]",
    "instance_renew_attribute": "[ {JSON data related to auto-renewal}, ...]",
    "instances_full_status"  : "[ {JSON data related to full status information}, ...]",
    "OperationLocks"         : "[ {JSON data related to lock reasons}, ...]",
    "Memory"                 : "8192",
    "Cpu"                    : "4",
    "InternetMaxBandwidthOut": "0",
    "InternetMinBandwidthIn" : "0",
    "AutoReleaseTime"        : "xxxx",
    "Tags"                   : "{Tags configured on the cloud platform}"
    "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.disks, fields.network_interfaces, fields.instance_renew_attribute, fields.instances_full_status, fields.OperationLocks are all strings serialized in JSON format.

X. Appendix

Please refer to the official Alibaba Cloud documentation: