Skip to content

Commit 3614947

Browse files
committed
Add ADOT resource monitoring example
Signed-off-by: Wesley Pettit <[email protected]>
1 parent 60f13e2 commit 3614947

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ We want examples of as many use cases in this repository as possible! Submit a P
2525
### Monitoring Fluent Bit
2626
* [Send Fluent Bit internal metrics to CloudWatch](examples/fluent-bit/send-fb-internal-metrics-to-cw)
2727
* [Fluent Bit Container Health Check Options](examples/fluent-bit/health-check)
28+
* [CPU, Disk, and Memory Usage Monitoring with ADOT](examples/fluent-bit/adot-resource-monitoring/)
2829

2930
### Fluent Bit Examples
3031

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# FireLens Example: Quickly Enable Resource Monitoring with ADOT
2+
3+
The [AWS Distro for OpenTelemetry](https://aws-otel.github.io/) has many features for collecting telemetry from your applications. In this tutorial, you will learn how to quickly enable resource utilization monitoring for Fluent Bit using ADOT. OpenTelemetry can do a lot more than is shown in this tutorial.
4+
5+
This guide is broken down into two tutorials:
6+
- [Tutorial 1: Quickly Enable Task Resource Monitoring](#tutorial-1-quickly-enable-task-resource-monitoring)
7+
- [Tutorial 2: Enable Container Level Metric Collection](#tutorial-2-enable-container-level-metric-collection)
8+
9+
### Tutorial 1: Quickly Enable Task Resource Monitoring
10+
11+
To quickly enable CPU, memory, network and disk usage metrics for your FireLens task, simply add the following container definition to your current task definition:
12+
13+
```
14+
{
15+
"essential": true,
16+
"image": "public.ecr.aws/aws-observability/aws-otel-collector:latest",
17+
"name": "aws-otel-collector",
18+
"logConfiguration": {
19+
"logDriver": "awslogs",
20+
"options": {
21+
"awslogs-group": "aws-otel-collector",
22+
"awslogs-region": "us-west-1",
23+
"awslogs-create-group": "true",
24+
"awslogs-stream-prefix": "ecs-"
25+
}
26+
},
27+
"memoryReservation": 100,
28+
"command": [
29+
"--config=/etc/ecs/container-insights/otel-task-metrics-config.yaml"
30+
]
31+
}
32+
```
33+
34+
This uses the [built-in ADOT configuration](https://github.com/aws-observability/aws-otel-collector/blob/main/config/ecs/container-insights/otel-task-metrics-config.yaml) for ECS Task Level Metrics. Please read the full [documentation](https://aws-otel.github.io/docs/components/ecs-metrics-receiver).
35+
36+
This configuration will send metrics to CloudWatch with the following sets of dimensions:
37+
- `ClusterName`
38+
- `ClusterName` and `TaskDefinitionFamily`
39+
40+
This means that you will get CPU, Memory, Disk, and Network metrics for the entire task aggregated across your cluster, and the union of cluster and TaskDefinition Family.
41+
42+
### Tutorial 2: Enable Container Level Metric Collection
43+
44+
For this tutorial, you must do the following:
45+
46+
1. Copy the "Full configuration for task- and container-level metrics" example from the [ADOT ECS Documentation](https://aws-otel.github.io/docs/components/ecs-metrics-receiver).
47+
2. Optionally modify the dimensions and metrics sent to CloudWatch with the `awsemf` exporter. For example, you could add `TaskId` and `ContainerName` as dimensions to monitoring specific Fluent Bit containers. However, please understand that this will lead to a very large number of individual metrics in CloudWatch which will induce cost.
48+
3. Follow the [ADOT ECS Custom Config tutorial](https://aws-otel.github.io/docs/setup/ecs/config-through-ssm) to run ADOT with your custom configuration.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [{
4+
"Effect": "Allow",
5+
"Action": [
6+
"logs:CreateLogStream",
7+
"logs:CreateLogGroup",
8+
"logs:PutLogEvents"
9+
],
10+
"Resource": "*"
11+
}]
12+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"family": "firelens-example-cloudwatch",
3+
"taskRoleArn": "arn:aws:iam::XXXXXXXXXXXX:role/ecs_task_iam_role",
4+
"executionRoleArn": "arn:aws:iam::XXXXXXXXXXXX:role/ecs_task_execution_role",
5+
"containerDefinitions": [
6+
{
7+
"essential": true,
8+
"image": "906394416424.dkr.ecr.us-east-1.amazonaws.com/aws-for-fluent-bit:stable",
9+
"name": "log_router",
10+
"firelensConfiguration": {
11+
"type": "fluentbit"
12+
},
13+
"logConfiguration": {
14+
"logDriver": "awslogs",
15+
"options": {
16+
"awslogs-group": "firelens-container",
17+
"awslogs-region": "us-west-2",
18+
"awslogs-create-group": "true",
19+
"awslogs-stream-prefix": "firelens"
20+
}
21+
},
22+
"memoryReservation": 50
23+
},
24+
{
25+
"essential": true,
26+
"image": "public.ecr.aws/aws-observability/aws-otel-collector:latest",
27+
"name": "aws-otel-collector",
28+
"logConfiguration": {
29+
"logDriver": "awslogs",
30+
"options": {
31+
"awslogs-group": "aws-otel-collector",
32+
"awslogs-region": "us-west-1",
33+
"awslogs-create-group": "true",
34+
"awslogs-stream-prefix": "ecs-"
35+
}
36+
},
37+
"memoryReservation": 100,
38+
"command": [
39+
"--config=/etc/ecs/container-insights/otel-task-metrics-config.yaml"
40+
]
41+
},
42+
{
43+
"essential": true,
44+
"image": "nginx",
45+
"name": "app",
46+
"logConfiguration": {
47+
"logDriver":"awsfirelens",
48+
"options": {
49+
"Name": "cloudwatch_logs",
50+
"region": "us-west-2",
51+
"log_key": "log",
52+
"log_group_name": "ecs/application",
53+
"auto_create_group": "true",
54+
"log_stream_prefix": "app-",
55+
"retry_limit": "2"
56+
}
57+
},
58+
"memoryReservation": 100
59+
}
60+
]
61+
}

0 commit comments

Comments
 (0)