Collector "Alibaba Cloud - ECS" 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 collect data from |
regions[#] |
str | Required | Region ID. Example: 'cn-hangzhou' See appendix for full list |
2. Configuration Examples¶
Specifying Regions¶
Collect data from Hangzhou and Shanghai regions
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 |
---|---|
name | Instance ID |
HostName | Instance ID |
InstanceName | Instance hostname |
InstanceId | Instance ID |
ZoneId | Availability zone ID |
InstanceChargeType | Instance billing method. Possible values: PrePaid: Subscription. PostPaid: Pay-as-you-go. |
InternetChargeType | Elastic IP billing method. Possible values: PayByBandwidth: Bandwidth-based billing. PayByTraffic: Traffic-based billing. |
OSType | Instance operating system |
PublicIpAddress_IpAddress | List of public IPs of the instance |
InstanceType | Instance specification |
InstanceTypeFamily | Instance specification family |
Status | Instance status |
# Example: Enable filter to filter objects based on InstanceId and name attributes, configuration format 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 integration_core__runner import Runner
import integration_alibabacloud_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 successfully synchronized, you can view the data in the "Infrastructure - Resource Catalog" of TrueWatch.
Example of reported data:
{
"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 interface 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" : "{Tags configured on the cloud platform}"
"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 the unique identifier. fields.message, fields.disks, fields.network_interfaces, fields.instance_renew_attribute, fields.instances_full_status, fields.OperationLocks are all JSON serialized strings.
X. Appendix¶
Please refer to the official Alibaba Cloud documentation: