Skip to content

Collector "AWS-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 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 the appendix for the complete list

2. Configuration Example

Collect instance data from the Beijing region

collector_configs = {
    'regions': ['cn-north-1' ]
}

Configuration Filter (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
clusterArn Amazon Resource Name (ARN) identifying the cluster
clusterName User-generated string identifying the cluster
status Status of the cluster
attachmentsStatus Status of the capacity providers associated with the cluster
# Example: Enable the filter to filter based on the attachmentsStatus and status attributes of the object. The configuration format is as follows:
def filter_instance(instance):
    '''
    Collect instances with instance_id as xxx and engine as mysql
    '''
    # return True
    attachments_status = instance['attachmentsStatus']
    status = instance['status']
    if attachments_status in ['UPDATE_COMPLETE'] and status in ['ACTIVE']:
        return True
    return False


@DFF.API('AWS-ECS Collection', timeout=3600, fixed_crontab='* * * * *')
def run():
    Runner(main.DataCollector(account, collector_configs, filters=[filter_instance])).run()

3. Data Reporting Format

After successful data synchronization, you can view the data in the "Infrastructure - Resource Catalog" of TrueWatch.

Example of reported data:

{
  "measurement": "aws_ecs",
  "tags": {
    "attachmentsStatus"                 : "xxxx",
    "RegionId"                          : "xxxx",
    "status"                            : "ACTIVE",
    "clusterName"                       : "xxxx",
    "clusterArn"                        : "xxxx",
    "name"                              : "xxxx"
  },
  "fields": {
    "registeredContainerInstancesCount" : "xxxx",
    "runningTasksCount"                 : 1,
    "pendingTasksCount"                 : 1,
    "activeServicesCount"               : "xxxx",
    "message"                           : "{Instance JSON Data}"
  }
}
Note

The fields in tags and fields may change with subsequent updates.

4. IAM Policy Permissions

Note

If users use the IAM role method to collect resources, certain operation permissions need to be enabled.

This collector requires the following permissions:

ecs:ListClusters

ecs:DescribeClusters

X. Appendix

Please refer to the AWS official documentation: