# Can Prometheus scrape targets from AWS EC2 instances in multiple AWS regions?

**URL:** https://discuss.prometheus.io/t/can-prometheus-scrape-targets-from-aws-ec2-instances-in-multiple-aws-regions/988
**Category:** Prometheus server
**Created:** [May 13, 2022, 9:56am UTC](https://discuss.prometheus.io/t/can-prometheus-scrape-targets-from-aws-ec2-instances-in-multiple-aws-regions/988 "2022-05-13T09:56:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![erlendo](https://avatars.discourse-cdn.com/v4/letter/e/82dd89/32.png) [@erlendo](https://discuss.prometheus.io/u/erlendo)
#### Post date: [May 13, 2022, 9:56am UTC](https://discuss.prometheus.io/t/can-prometheus-scrape-targets-from-aws-ec2-instances-in-multiple-aws-regions/988/1 "2022-05-13T09:56:23Z")

</div>

I have a Prometheus docker container (v2.35.0) running in AWS ECS, and I’m struggling with configuring it correctly so that targets from EC2 instances in multiple regions are scraped.

My current ‘scrape\_configs’ section in ‘prometheus.yml’ looks like this:

```auto
scrape_configs:
  - job_name: ec2_instances
    metrics_path: /metrics
    ec2_sd_configs:
      - region: eu-central-1
        profile: arn:aws:iam::67.....
        port: 18080
        filters:
          - name: "tag:erlendo:prometheus-filter"
            values:
              - erlendo_1
      - region: eu-west-1
        profile: arn:aws:iam::67.....
        port: 18080
        filters:
          - name: "tag:erlendo:prometheus-filter"
            values:
              - erlendo_2

```

With this configuration, only EC2 instances running in ‘eu-central-1’ gets scraped, and I see the following error message in Prometheus log:

```auto
ts=2022-05-13T09:36:47.949Z caller=refresh.go:98 level=error component="discovery manager scrape" discovery=ec2 msg="Unable to refresh target groups" err="could not describe instances: MissingEndpoint: 'Endpoint' configuration is required for this service"

```

If I switch the order of the 2 ‘ec2\_sd\_config’ entries, only the EC2 instances in ‘eu-west-1’ gets scraped, and the same error message appears in Prometheus log.

I also tried adding ‘endpoint: “[https://ec2.eu-west-1.amazonaws.com](https://ec2.eu-west-1.amazonaws.com)”’ to the second ‘ec2\_sd\_config’ entry, but then I got the following error in Prometheus log:

```auto
ts=2022-05-12T14:09:15.831Z caller=refresh.go:98 level=error component="discovery manager scrape" discovery=ec2 msg="Unable to refresh target groups" err="could not describe instances: AuthFailure: AWS was not able to validate the provided access credentials\n\tstatus code: 401, request id: 5a70393a-790d-4114-9925-2ac38d3ff08e"

```

I don’t have much experience in using Prometheus, so I would appreciate if anyone could help making this scenario work.

---

<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: [February 22, 2024, 7:32pm UTC](https://discuss.prometheus.io/t/can-prometheus-scrape-targets-from-aws-ec2-instances-in-multiple-aws-regions/988/2 "2024-02-22T19:32:44Z")

</div>

I am having the same issue. Any one have any insight on this or suggestions?
