Skip to content

Collector Configuration Manual for "AWS-ECS"

Before reading this, please first read:

Before using this collector, you must install the 'Integration Core Package' and its associated third-party dependency packages

1. Configuration Structure

The configuration structure for 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-north-1'
See full list in the appendix

2. Configuration Example

Collecting instance data from the Beijing region

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

Configuring Filters (Optional)

This collector script supports user-defined filters that allow users to filter target resources by 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 properties:

Property Description
clusterArn AmazonResourceName (ARN) identifying the cluster
clusterName User-generated string identifying the cluster
status Status of the cluster
attachmentsStatus Status of capacity providers associated with the cluster
Python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Example: Enable a filter based on the attachmentsStatus and status properties of an object, configuration format as follows:
def filter_instance(instance):
    '''
    Collect instances where instance_id is xxx and engine is 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 data is synchronized successfully, it can be viewed in the {{( brand_name )}} "Infrastructure - Resource Catalog".

An example of reported data is as follows:

JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{
  "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}"
  }
}

Fields in tags and fields may change with subsequent updates

4. IAM Policy Permissions

If the user collects resources using an IAM role, certain operation permissions need to be enabled

This collector requires the following permissions:

ecs:ListClusters

ecs:DescribeClusters

X. Appendix

Please refer to the official AWS documentation: