# Metricbeat AWS module error while using credentials\_profile\_name

**URL:** <https://discuss.elastic.co/t/metricbeat-aws-module-error-while-using-credentials-profile-name/264807>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [February 19, 2021, 7:35am UTC](https://discuss.elastic.co/t/metricbeat-aws-module-error-while-using-credentials-profile-name/264807 "2021-02-19T07:35:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![atharvak](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@atharvak](https://discuss.elastic.co/u/atharvak)\
**Post date:** [February 19, 2021, 7:35am UTC](https://discuss.elastic.co/t/metricbeat-aws-module-error-while-using-credentials-profile-name/264807/1 "2021-02-19T07:35:45Z")

</div>

Hello guys,  
I am trying to configure AWS metrics for multiple AWS accounts of mine. I have already configured the profiles using AWS CLI and they are working. But when the same profile name is put in the `modules.d/aws.yml` it is showing errors.  
My configuration and error is below.

# Config

`modules.d/aws.yml`

```auto
- module: aws
  period: 1m
  credential_profile_name: elastic-profile
  metricsets:
    - elb
    - usage
- module: aws
  period: 24h
  credential_profile_name: elastic-profile
  metricsets:
    - s3_daily_storage
    - s3_request
- module: aws
  period: 15m
  credential_profile_name: elastic-profile
  metricsets:
    - ebs
    - ec2
    - sns
    - sqs
    - rds

```

# Error

```auto
Feb 19 13:02:40 elkserver metricbeat: caused by: Get http://169.254.169.254/latest/meta-data/iam/security-credentials: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers); error creating aws metricset: failed to retrieve aws credentials, please check AWS credential in config: EC2RoleRequestError: no EC2 instance role found
Feb 19 13:02:40 elkserver metricbeat: Exiting: 2 errors: error creating aws metricset: failed to retrieve aws credentials, please check AWS credential in config: EC2RoleRequestError: no EC2 instance role found
Feb 19 13:02:40 elkserver metricbeat: caused by: RequestError: send request failed
Feb 19 13:02:40 elkserver metricbeat: caused by: Get http://169.254.169.254/latest/meta-data/iam/security-credentials: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers); error creating aws metricset: failed to retrieve aws credentials, please check AWS credential in config: EC2RoleRequestError: no EC2 instance role found

```

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [February 19, 2021, 11:28am UTC](https://discuss.elastic.co/t/metricbeat-aws-module-error-while-using-credentials-profile-name/264807/2 "2021-02-19T11:28:12Z")

</div>

Hi @atharvak,

Umm, this seems to be failing to connect with the metadata endpoint (timeouts to `http://169.254.169.254`). Is Metricbeat deployed in AWS?

In any case I wonder why it tries to get the security credentials from this endpoint if they are already being provided in the credential file.

Do you see any other error accessing the credentials file?  
If you don't have the credentials file in the default path, you may need to set `shared_credential_file` to the directory containing the `credentials` file.

---

<div class="post-metadata">

**Author:** ![atharvak](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@atharvak](https://discuss.elastic.co/u/atharvak)\
**Post date:** [February 19, 2021, 4:27pm UTC](https://discuss.elastic.co/t/metricbeat-aws-module-error-while-using-credentials-profile-name/264807/3 "2021-02-19T16:27:25Z")

</div>

Did not understand how it happened, but when I gave absolute path for credentials file using `shared_credential_file` and provided the `credential_profile_name`, it started working.  
Thank you so much!  
Following config might help people with same issue.

```auto
- module: aws
  period: 1m
  shared_credential_file: /root/.aws/credentials
  credential_profile_name: elastic-profile
  metricsets:
    - elb
    - usage

```

---

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [February 19, 2021, 4:32pm UTC](https://discuss.elastic.co/t/metricbeat-aws-module-error-while-using-credentials-profile-name/264807/4 "2021-02-19T16:32:45Z")

</div>

@atharvak good to see this worked for you 🙂

With what user are you running `metricbeat`? If this is running as root I think that it should be able to find the credentials file in this path without the need of `shared_credential_file`.

---

<div class="post-metadata">

**Author:** ![atharvak](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@atharvak](https://discuss.elastic.co/u/atharvak)\
**Post date:** [February 20, 2021, 7:45am UTC](https://discuss.elastic.co/t/metricbeat-aws-module-error-while-using-credentials-profile-name/264807/5 "2021-02-20T07:45:31Z")

</div>

Uh, no. My `metricbeat` is run by `root` user only. But when I commented out the `shared_credentials_file` it started showing the same error again. I don't know why...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 20, 2021, 9:46am UTC](https://discuss.elastic.co/t/metricbeat-aws-module-error-while-using-credentials-profile-name/264807/6 "2021-03-20T09:46:00Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
