diff --git a/knowledge base/cloud computing/aws/ecs.md b/knowledge base/cloud computing/aws/ecs.md index fc0e89d..de242b9 100644 --- a/knowledge base/cloud computing/aws/ecs.md +++ b/knowledge base/cloud computing/aws/ecs.md @@ -13,6 +13,7 @@ 1. [Docker volumes](#docker-volumes) 1. [Bind mounts](#bind-mounts) 1. [Execute commands in tasks' containers](#execute-commands-in-tasks-containers) +1. [Scrape metrics using Prometheus](#scrape-metrics-using-prometheus) 1. [Troubleshooting](#troubleshooting) 1. [Invalid 'cpu' setting for task](#invalid-cpu-setting-for-task) 1. [Further readings](#further-readings) @@ -359,10 +360,14 @@ EFS file systems are supported on ### Docker volumes +Refer [Use Docker volumes with Amazon ECS]. + TODO ### Bind mounts +Refer [Use bind mounts with Amazon ECS]. + TODO ## Execute commands in tasks' containers @@ -560,6 +565,28 @@ Logging options are configured at the ECS cluster level.
The task's role **will** need to have IAM permissions to log the output to S3 and/or CloudWatch should the cluster be configured for the above options. If the options are **not** configured, then the permissions are **not** required. +## Scrape metrics using Prometheus + +Refer [Prometheus service discovery for AWS ECS] and [Scraping Prometheus metrics from applications running in AWS ECS]. + +> Prometheus is **not** currently capable to automatically discover ECS components like services or tasks. + +Solutions: + +- _Push_ the metrics instead by instrumenting the applications, or using tools like [AWS Distro for OpenTelemetry]. +- Use a load balancer to access the service, and point Prometheus to the load balancer. + + Useful if needing to just monitor the availability of services.
+ The load balancer will take care of monitoring the tasks in the target group. + + The scrape request needs to go through the load balancer.
+ This **will** cost money. + +- Target a lambda that returns a [308 Permanent Redirect] code with the current IP addresses of the requested tasks. +- Use dynamic service discovery mechanisms like AWS Cloud Map.
+ Refer [Metrics collection from Amazon ECS using Amazon Managed Service for Prometheus] and + [aws-cloudmap-prometheus-sd]. + ## Troubleshooting ### Invalid 'cpu' setting for task @@ -614,6 +641,11 @@ Specify a supported value for the task CPU and memory in your task definition. - [Using Amazon ECS Exec to access your containers on AWS Fargate and Amazon EC2] - [A Step-by-Step Guide to Enabling Amazon ECS Exec] - [`aws ecs execute-command` results in `TargetNotConnectedException` `The execute command failed due to an internal error`] +- [Prometheus service discovery for AWS ECS] +- [Metrics collection from Amazon ECS using Amazon Managed Service for Prometheus] +- [AWS Distro for OpenTelemetry] +- [aws-cloudmap-prometheus-sd] +- [Scraping Prometheus metrics from applications running in AWS ECS] [`aws ecs execute-command` results in `TargetNotConnectedException` `The execute command failed due to an internal error`]: https://stackoverflow.com/questions/69261159/aws-ecs-execute-command-results-in-targetnotconnectedexception-the-execute +[308 Permanent Redirect]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308 [a step-by-step guide to enabling amazon ecs exec]: https://medium.com/@mariotolic/a-step-by-step-guide-to-enabling-amazon-ecs-exec-a88b05858709 [attach ebs volume to aws ecs fargate]: https://medium.com/@shujaatsscripts/attach-ebs-volume-to-aws-ecs-fargate-e23fea7bb1a7 +[aws-cloudmap-prometheus-sd]: https://github.com/awslabs/aws-cloudmap-prometheus-sd [exposing multiple ports for an aws ecs service]: https://medium.com/@faisalsuhail1/exposing-multiple-ports-for-an-aws-ecs-service-64b9821c09e8 [guide to using amazon ebs with amazon ecs and aws fargate]: https://stackpioneers.com/2024/01/12/guide-to-using-amazon-ebs-with-amazon-ecs-and-aws-fargate/ +[prometheus service discovery for aws ecs]: https://tomgregory.com/aws/prometheus-service-discovery-for-aws-ecs/ +[Scraping Prometheus metrics from applications running in AWS ECS]: https://towardsaws.com/scraping-prometheus-metrics-from-aws-ecs-9c8d9a1ca1bd