NoteAmazon ECS capabilities in the Tanzu CloudHealth are going to be deprecated soon.
VMware Tanzu CloudHealth digests CloudWatch ECS events to report cluster cost allocation and utilization.
ECS generates CloudWatch Events for ECS state changes. Tanzu CloudHealth digests these events in order to report cluster cost allocation and utilization.
The Tanzu CloudHealth ECS module uses CloudWatch to gather ECS Events and store them in an S3 bucket that you create. An IAM Policy, specifying a designated Tanzu CloudHealth Role, is associated with the S3 bucket, permitting Tanzu CloudHealth to retrieve Events from the bucket.
Note
For which accounts should you enable the ECS Module? All AWS accounts that are configured in the Tanzu CloudHealth Platform and own ECS infrastructure that you want to analyze using Tanzu CloudHealth.
Note Repeat these steps for each AWS Account whose ECS infrastructure you want to analyze using Tanzu CloudHealth.
Download the CloudFormation template from this location and save it locally as ecs-event-pipeline-generic-template.json
.
The template performs the following operations in your AWS Account.
What data does Tanzu CloudHealth gather? Tanzu CloudHealth gathers two categories of data: (a) What node-level hardware resources are available in terms of Memory, CPU, and Disk. (b) What workloads are running in the cluster, and their resource allocation, measured in terms of Memory, CPU, and Disk.
Run this command for each AWS Account.
Enter the AWS Account ID, S3 Bucket name, and S3 Bucket prefix in the placeholders in the command.
export ACCOUNT_ID=[place ACCOUNT ID here]
export BUCKET_NAME=[place BUCKET NAME here]
export BUCKET_PREFIX=[place BUCKET PREFIX here]
aws cloudformation create-stack
--stack-name cht-ecs-event-stream-bucket-stack-${ACCOUNT_ID} \
--parameters ParameterKey=S3Bucket,ParameterValue=${BUCKET_NAME} ParameterKey=S3BucketPrefix,ParameterValue=${BUCKET_PREFIX} \
--template-body file://./ecs-event-pipeline-generic-template.json \
--capabilities CAPABILITY_NAMED_IAM
Provide Tanzu CloudHealth read-only access to your Amazon ECS infrastructure and the S3 Buckets that store ECS Events.
In the IAM Access Policy dialog box, click Select All and copy the contents to the clipboard. The updated policy contains two sets of read-only privileges. This set provides Tanzu CloudHealth read-only access to the ECS infrastructure in the AWS Account. "ecs:List*", "ecs:Describe*"
This set provides Tanzu CloudHealth read-only access to the S3 bucket that stores ECS Events.
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": [
"arn:aws:s3:::cht-ecs-event-stream-bucket-<AWS-Account-Number>",
"arn:aws:s3:::cht-ecs-event-stream-bucket-<AWS-Account-Number>/*"
]
},
How long does it take for ECS clusters to be discovered and listed in the Tanzu CloudHealth Platform? Tanzu CloudHealth polls for changes to the IAM Policy every 15 min. The two lines you enter in the policy allow Tanzu CloudHealth to get a list of all ECS clusters in your AWS Accounts. Depending on when the polling last occurred with respect to the timing of changes to the policy, you might need to wait at least 15 min for your ECS clusters to appear in the Tanzu CloudHealth Platform.
In the Tanzu CloudHealth Platform, from the left menu, select Setup > Containers > Clusters. Once your ECS clusters are discovered, they appear on the page.
What if no clusters appear on this page?
If clusters are not listed on this page, Tanzu CloudHealth is still in the process of reading your ECS infrastructure. Return to this page later to see if the list is populated.
The CloudFormation Stack that you previously deployed in your AWS Account allows Tanzu CloudHealth to immediately start collecting metadata from the orchestrator. The Status of the cluster switches to Healthy once Tanzu CloudHealth starts receiving data.
Historical information is not backfilled.
Meaningful visualizations appear in the Tanzu CloudHealth platform approximately 24 hours after the Stack has been deployed and has started pushing data.
On the Setup > Containers > Clusters page, clusters can have one of three statuses:
Tanzu CloudHealth currently does not support Fargate cluster metrics.
Configure Kinesis Firehose to stream ECS-related CloudWatch events to an S3 bucket.
Repeat these steps in each region in which you have ECS usage, and ensure that you use the same S3 bucket and IAM role for all the regions you configure.
ecs-event-stream/<account_id>/
.Configure an ECS CloudWatch rule and connect Kinesis Firehose to the CloudWatch rule.
Repeat these steps in each region in which you have ECS usage, and ensure that you use the same IAM role for all the regions you configure.
cht-ecs-event-stream-ecs-to-firehose-rule-<insert-region-name>
CloudWatch Events Rule configured to deliver all ECS events to Kinesis Firehose
Generate a policy that provides the IAM Role associated with the Tanzu CloudHealth Platform access to the S3 bucket that stores the Kinesis Firehose streams.
Scroll to the bottom of the page and click Generate Policy. Copy the contents of the IAM Access Policy dialog box to the clipboard. The policy should include the following definition:
"ecs:List*",
"ecs:Describe*",
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": [
"arn:aws:s3:::<yourbucketname>",
"arn:aws:s3:::<yourbucketname>/*"
]
}
Close the IAM Access Policy dialog box and click Save Account.
Update the policy for the IAM Role associated with the Tanzu CloudHealth Platform.
Add the appropriate S3 Bucket Policy to allow Tanzu CloudHealth to retrieve data from the bucket.
Copy and paste the following policy document into the Bucket policy editor. Then click Save.
{
"Version": "2012-10-17",
"Id": "cht-ecs-bucket-policy",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::146708650527:role/CloudHealth-IAM-Role"
},
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": "arn:aws:s3:::<insert bucket name>"
}
]
}
In the Tanzu CloudHealth Platform, from the left menu, select Setup > Containers > Clusters. The clusters for all the account and region combinations you configured appear on this page and should indicate a healthy status.