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'
See appendix for full list

2. Configuration Example

Specifying Regions

Collecting 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: 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 Elastic public IP billing method. Possible values:
PayByBandwidth: Billing by bandwidth.
PayByTraffic: Billing by traffic.
OSType Instance operating system
PublicIpAddress_IpAddress List of public IPs for 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, filtering by the InstanceId and name properties of the object, with the following configuration format:
def filter_instance(instance):
    '''
    Collect instances where instance_id is xxxxx or instance_name is 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 is synchronized successfully, it can be viewed in the «Infrastructure - Resource Catalog» section of Guance and TrueWatch.

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"                  : "[ {associated disk JSON data}, ... ]",
    "network_interfaces"     : "[ {associated network card JSON data}, ... ]",
    "instance_renew_attribute": "[ {auto-renewal JSON data}, ...]",
    "instances_full_status"  : "[ {full status information JSON data}, ...]",
    "OperationLocks"         : "[ {lock reason JSON data}, ...]",
    "Memory"                 : "8192",
    "Cpu"                    : "4",
    "InternetMaxBandwidthOut": "0",
    "InternetMinBandwidthIn" : "0",
    "AutoReleaseTime"        : "xxxx",
    "Tags"                   : "{cloud platform configured Tags}",
    "message"                : "{instance JSON data}"
  }
}

Fields in tags and fields may change with subsequent updates

tags.name value 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

Refer to the official Alibaba Cloud documentation: