Collector 'AWS-EC2' Configuration Manual¶
Before reading this document, please read:
Tip
Before using this collector, you must install the 'Integration Core Core Package' and its accompanying 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 be collected |
regions[#] |
str | Required | Region ID. For example: 'cn-north-1' See appendix for the complete list |
2. Configuration Examples¶
Specifying Regions¶
Collect instance data from Ningxia and Beijing 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|False
- True: The target resource should be collected.
- False: The target resource should not be collected
Supported object attributes for filtering:
Attribute | Description |
---|---|
InstanceId |
Instance ID |
RegionId |
Region ID |
PlatformDetails |
Operating System |
InstanceType |
Instance Type |
InstanceName |
Instance Name |
When custom object collection is enabled, supported object attributes for filtering can be found in the corresponding documentation
- Cloud Assets (Object Data)/Elastic Compute Cloud (EC2)
- Cloud Assets (Object Data)/Relational Database Service (RDS)
# Example: Enabling a filter to filter objects based on InstanceId and RegionId attributes, configured as follows:
def filter_instance(instance, namespace='AWS/EC2'):
'''
Collect instances with InstanceId i-xxxxxa, i-xxxxxb
'''
instance_id = instance['tags'].get('InstanceId')
if instance_id in ['i-xxxxxa', 'i-xxxxxb']:
return True
return False
from integration_core__runner import Runner
import integration_aws_ec2__main as main
@DFF.API('AWS-EC2 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, it can be viewed in the 'Infrastructure-Resource Catalog' of TrueWatch.
Example of reported data:
{
"measurement": "aws_ec2",
"tags": {
"name" : "i-0d7620xxxxxxx",
"InstanceId" : "i-0d7620xxxxxxx",
"InstanceType" : "c6g.xlarge",
"PlatformDetails" : "Linux/UNIX",
"RegionId" : "cn-northwest-1",
"InstanceName" : "test",
"State" : "running",
"StateReason_Code": "Client.UserInitiatedHibernate",
"AvailabilityZone": "cn-northwest-1",
},
"fields": {
"BlockDeviceMappings": "{Device JSON Data}",
"LaunchTime" : "2021-10-26T07:00:44Z",
"NetworkInterfaces" : "{Network JSON Data}",
"Placement" : "{Availability Zone JSON Data}",
"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.
Tip
fields.message, fields.NetworkInterfaces, fields.BlockDeviceMappings are JSON serialized strings.
4. IAM Policy Permissions¶
Note
If users use the method of bringing in IAM roles to collect resources, certain operation permissions need to be enabled.
This collector requires the following operation permissions:
ec2:DescribeInstances
X. Appendix¶
Please refer to the AWS official documentation: