Skip to content

Commit 70405b9

Browse files
ruchimobonclay7
andauthored
Adding Module and Example for ECS cluster monitoring with ecs_observer (#211)
* Adding Module and Example for ECS cluster monitoring with ecs_observer * Adding Module and Example for ECS cluster monitoring with ecs_observer * Incorporating PR comments * Restructuring Examples and modules folder for ECS, Added content in main Readme * Fixing path as per PR comments * Parameterzing the config files, incorporated PR review comments * Adding condition for AMP WS and fixing AMP endpoint * Adding Document for ECS Monitoring and parameterized some variables * Added sample dashboard * Adding Document for ECS Monitoring and parameterized some variables * Fixing failures detected by pre-commit * Fixing failures detected by pre-commit * Fixing failures detected by pre-commit * Pre-commit fixes * Fixing failures detected by pre-commit * Fixing failures detected by pre-commit * Pre-commit * Fixing HIGH security alerts detected by pre-commit * Fixing HIGH security alerts detected by pre-commit * Fixing HIGH security alerts detected by pre-commit, 31stOct * Add links after merge * 2ndNov - Added condiotnal creation for Grafana WS and module versions for AMG, AMP --------- Co-authored-by: Rodrigue Koffi <[email protected]>
1 parent 0b42935 commit 70405b9

File tree

17 files changed

+863
-0
lines changed

17 files changed

+863
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,18 @@ module "eks_monitoring" {
127127
}
128128
```
129129

130+
#### Amazon ECS monitoring
131+
ECS cluster with VPC and EC2 can be created using the example [here](./examples/ecs_cluster_with_vpc)
132+
133+
```hcl
134+
module "ecs_monitoring" {
135+
source = "github.com/aws-observability/terraform-aws-observability-accelerator//modules/ecs-monitoring"
136+
137+
aws_ecs_cluster_name = module.ecs_cluster.cluster_name
138+
task_role_arn = module.ecs_cluster.task_exec_iam_role_arn
139+
execution_role_arn = module.ecs_cluster.task_exec_iam_role_arn
140+
}
141+
```
130142
Grafana Dashboards
131143

132144
<img width="2056" alt="image" src="https://user-images.githubusercontent.com/10175027/199110753-9bc7a9b7-1b45-4598-89d3-32980154080e.png">

docs/ecs/ecs-monitoring-on-ec2.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Amazon ECS on EC2 cluster monitoring
2+
3+
This example demonstrates how to monitor your Amazon Elastic Container Service on EC2
4+
(Amazon ECS) cluster with the Observability Accelerator's ECS monitoring module
5+
6+
The module collects Prometheus metrics from tasks running on ECS and sends it to Prometheus using AWS Distro for OpenTelemetry Collector (ADOT).
7+
You can either run the collector as a sidecar or deploy the collector as its own ECS service for entire cluster.
8+
ECS tasks with Prometheus endpoints are discovered using extension
9+
[ecsobserver](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/observer/ecsobserver/README.md).
10+
(Unlike EKS, there is no builtin discovery for ECS inside prometheus)
11+
12+
Additionally, you can optionally collect custom Prometheus metrics from your applications running
13+
on your ECS cluster.
14+
15+
## Prerequisites
16+
17+
!!! note
18+
Make sure to complete the [prerequisites section](https://aws-observability.github.io/terraform-aws-observability-accelerator/concepts/#prerequisites) before proceeding.
19+
20+
## Available Samples for various Worklods
21+
Make sure to update your exisitng Application Task Definitions based on the workload type :-
22+
23+
#### 1. [Java/JMX workload for ECS Clusters](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Sample-Workloads-ECS-javajmx.html)
24+
#### 2. [NGINX workload for Amazon ECS clusters](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Setup-nginx-ecs.html)
25+
#### 3. [App Mesh workload](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Sample-Workloads-ECS-appmesh.html)
26+
27+
## Setup
28+
29+
#### 1. Add the ECS Monitoring Module to your exisitng ECS CLuster
30+
31+
```
32+
module "ecs_monitoring" {
33+
source = "../../modules/ecs-monitoring"
34+
aws_ecs_cluster_name = module.ecs_cluster.cluster_name
35+
task_role_arn = module.ecs_cluster.task_exec_iam_role_arn
36+
execution_role_arn = module.ecs_cluster.task_exec_iam_role_arn
37+
38+
depends_on = [
39+
module.ecs_cluster
40+
]
41+
}
42+
```
43+
44+
## Deploy
45+
46+
Simply run this command to deploy the example
47+
48+
```bash
49+
terraform apply
50+
```
51+
52+
## Visualization
53+
![image](https://github.com/ruchimo/terraform-aws-observability-accelerator/assets/106240341/006c387e-92e8-45c8-ae2e-825900990741)
54+
55+
56+
## Cleanup
57+
58+
To clean up your environment, destroy the Terraform example by running
59+
60+
```sh
61+
terraform destroy
62+
```

docs/helpers/ecs-cluster-with-vpc.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Example Amazon ECS Cluster with VPC
2+
This example deploys an AWS ECS Cluster with VPC and also add the ECS Monitoring module
3+
4+
## Prerequisites
5+
6+
!!! note
7+
Make sure to complete the [prerequisites section](https://aws-observability.github.io/terraform-aws-observability-accelerator/concepts/#prerequisites) before proceeding.
8+
9+
## Setup
10+
#### 1. Download sources and initialize Terraform¶
11+
12+
```
13+
git clone https://github.com/aws-observability/terraform-aws-observability-accelerator.git
14+
cd terraform-aws-observability-accelerator/examples/ecs-cluster-with-vpc
15+
terraform init
16+
```
17+
18+
#### 2. AWS Region¶
19+
Specify the AWS Region where the resources will be deployed:
20+
21+
```
22+
export TF_VAR_aws_region=xxx
23+
```
24+
25+
#### 3. Terraform Plan to validate the changes/updates
26+
27+
```
28+
terraform plan
29+
```
30+
31+
## Deploy
32+
33+
Simply run this command to deploy the example
34+
35+
```bash
36+
terraform apply
37+
```
38+
39+
## Cleanup
40+
41+
To clean up your environment, destroy the Terraform example by running
42+
43+
```sh
44+
terraform destroy
45+
```
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# ECS Cluster w/ EC2 Autoscaling
2+
3+
Configuration in this directory creates:
4+
5+
- ECS cluster using EC2 autoscaling groups
6+
- Autoscaling groups with IAM instance profile to be used by ECS cluster
7+
- Example ECS service that utilizes
8+
- Mounts a host volume into the container definition
9+
- Load balancer target group attachment
10+
- Security group for access to the example service
11+
12+
## Usage
13+
14+
To run this example you need to execute:
15+
16+
```bash
17+
$ terraform init
18+
$ terraform plan
19+
$ terraform apply
20+
```
21+
22+
Note that this example may create resources which will incur monetary charges on your AWS bill. Run `terraform destroy` when you no longer need these resources.
23+
24+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
25+
## Requirements
26+
27+
| Name | Version |
28+
|------|---------|
29+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
30+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.55 |
31+
32+
## Providers
33+
34+
| Name | Version |
35+
|------|---------|
36+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.55 |
37+
38+
## Modules
39+
40+
| Name | Source | Version |
41+
|------|--------|---------|
42+
| <a name="module_alb_sg"></a> [alb\_sg](#module\_alb\_sg) | terraform-aws-modules/security-group/aws | ~> 5.0 |
43+
| <a name="module_autoscaling"></a> [autoscaling](#module\_autoscaling) | terraform-aws-modules/autoscaling/aws | ~> 6.5 |
44+
| <a name="module_autoscaling_sg"></a> [autoscaling\_sg](#module\_autoscaling\_sg) | terraform-aws-modules/security-group/aws | ~> 5.0 |
45+
| <a name="module_ecs_cluster"></a> [ecs\_cluster](#module\_ecs\_cluster) | terraform-aws-modules/ecs/aws | 5.2.2 |
46+
| <a name="module_ecs_monitoring"></a> [ecs\_monitoring](#module\_ecs\_monitoring) | ../../modules/ecs-monitoring | n/a |
47+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
48+
49+
## Resources
50+
51+
| Name | Type |
52+
|------|------|
53+
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
54+
| [aws_ssm_parameter.ecs_optimized_ami](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
55+
56+
## Inputs
57+
58+
No inputs.
59+
60+
## Outputs
61+
62+
No outputs.
63+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
64+
65+
## License
66+
67+
Apache-2.0 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-ecs/blob/master/LICENSE).

0 commit comments

Comments
 (0)