# AWS ECS Discovery containers

**URL:** <https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943>\
**Category:** Exporters and Metrics\
**Created:** [October 9, 2023, 9:27am UTC](https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943 "2023-10-09T09:27:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![r00t9](https://avatars.discourse-cdn.com/v4/letter/r/a9a28c/32.png) [@r00t9](https://discuss.prometheus.io/u/r00t9)\
**Post date:** [October 9, 2023, 9:27am UTC](https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943/1 "2023-10-09T09:27:39Z")

</div>

Prometheus support ECS discovery from APP Mesh or something else?

I can see Cloudwatch agent have ecs\_service\_discovery but they didn’t publish that to Prometheus and i don’t want to use Cloudwatch Prometheus.

I find this but the last update is two years.

> **[GitHub - teralytics/prometheus-ecs-discovery: A Prometheus discoverer that...](https://github.com/teralytics/prometheus-ecs-discovery)**
>
> A Prometheus discoverer that scrapes Amazon ECS and a generates file SD configuration file. - GitHub - teralytics/prometheus-ecs-discovery: A Prometheus discoverer that scrapes Amazon ECS and a gen...

How do you export your metrics from ECS ?

---

<div class="post-metadata">

**Author:** ![salessandri](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/salessandri/32/814_2.png) [@salessandri](https://discuss.prometheus.io/u/salessandri)\
**Post date:** [October 10, 2023, 3:40pm UTC](https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943/2 "2023-10-10T15:40:49Z")

</div>

What are you trying to get? Where to scrape the metrics from your containerized applications or to where to scrape ECS-specific metrics?

The latter - for example: desired containers or CPU utilization by an ECS service - are only exposed through AWS CloudWatch and there’s no other option than to use a cloudwatch exporter.

What the Prometheus ECS Discovery plugin will be helpful is to be able to dynamically find where to scrape the `/metrics` endpoint for your apps that expose Prometheus metrics.  
I haven’t used it, but I know there can be some wrinkles to iron if the number of containers you run in your environment is really large or it changes really frequently.

---

<div class="post-metadata">

**Author:** ![dburrows-poloniex](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/dburrows-poloniex/32/916_2.png) [@dburrows-poloniex](https://discuss.prometheus.io/u/dburrows-poloniex)\
**Post date:** [March 8, 2024, 5:08pm UTC](https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943/3 "2024-03-08T17:08:04Z")

</div>

@salessandri Did you find a solution to this?

---

<div class="post-metadata">

**Author:** ![salessandri](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/salessandri/32/814_2.png) [@salessandri](https://discuss.prometheus.io/u/salessandri)\
**Post date:** [March 9, 2024, 3:25am UTC](https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943/4 "2024-03-09T03:25:05Z")

</div>

@dburrows-poloniex Related to the OP, I was not able to understand what he was trying to achieve.

For what I had to do, extract CloudWatch metrics into a Prometheus consumer, I ended up developing my own exporter leveraging CloudWatch Stream.

What is it that you are trying to get done?

---

<div class="post-metadata">

**Author:** ![dburrows-poloniex](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/dburrows-poloniex/32/916_2.png) [@dburrows-poloniex](https://discuss.prometheus.io/u/dburrows-poloniex)\
**Post date:** [March 9, 2024, 11:45pm UTC](https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943/5 "2024-03-09T23:45:58Z")

</div>

@salessandri I have several ECS tasks that have there own metrics endpoints that I need to scrape like haproxy an well as many custom services. So I looking for a way to have my Prometheus server in a separate account be able to identify and scrape the containers endpoints.  
So I am looking for a discovery / exporter that will be able return to Prometheus the container IP at the very least.

I appreciate any thoughts or insights.

---

<div class="post-metadata">

**Author:** ![salessandri](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/salessandri/32/814_2.png) [@salessandri](https://discuss.prometheus.io/u/salessandri)\
**Post date:** [March 10, 2024, 11:29pm UTC](https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943/6 "2024-03-10T23:29:02Z")

</div>

I haven’t had to do that, yet. But it seems that the CloudWatch Agent has the capability of leveraging the API to generate a file that’s compatible with Prometheus’ file service discovery scraping. [This link](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContainerInsights-Prometheus-Setup-autodiscovery-ecs.html) is probably a good starting point. What is not clear to me after a quick look is whether it will parse and process all ECS tasks in a single host.

The option I had found a while back is what the OP linked. It seemed to work fine but if you have a large number of ECS tasks then the discovery process would take too long to finish.

---

<div class="post-metadata">

**Author:** ![alxts](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@alxts](https://discuss.prometheus.io/u/alxts)\
**Post date:** [August 28, 2024, 1:14am UTC](https://discuss.prometheus.io/t/aws-ecs-discovery-containers/1943/7 "2024-08-28T01:14:37Z")

</div>

If anyone is looking for dynamic ECS service discovery of ECS Clusters - check out this blog post:

> **[Scraping Prometheus metrics from AWS ECS](https://medium.com/@alxtsbk/scraping-prometheus-metrics-from-aws-ecs-9c8d9a1ca1bd)**
>
> If you are running your application(s) in AWS ECS Cluster(s) at some point you might start to wonder — how to scrape Prometheus metrics…

It provides dynamic service discovery of your ECS Tasks running in AWS ECS Cluster and exposes HTTP endpoint that is compatible with http\_sd\_target of Prometheus.

Also available on GitHub:

> **[GitHub - apptality/aws-ecs-cloudmap-prometheus-sd: Application allows Prometheus to discover ECS...](https://github.com/apptality/aws-ecs-cloudmap-prometheus-sd)**
>
> Application allows Prometheus to discover ECS containers running in Fargate cluster through http\_sd\_configs
