# AWS through Proxy

**URL:** https://discuss.elastic.co/t/aws-through-proxy/232022
**Category:** Beats
**Tags:** metricbeat
**Created:** [May 11, 2020, 1:16pm UTC](https://discuss.elastic.co/t/aws-through-proxy/232022 "2020-05-11T13:16:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![spike83](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spike83/32/47036_2.png) [@spike83](https://discuss.elastic.co/u/spike83)
#### Post date: [May 11, 2020, 1:16pm UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/1 "2020-05-11T13:16:36Z")

</div>

Hi,

How can I add a proxy setting the the AWS module to get to the outside world? I appear to run into issues using the system variable https\_proxy when outputting to elastic internally, I can either get to AWS and not Elastic, or to Elastic and not AWS

Regards

---

<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: [May 11, 2020, 2:15pm UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/2 "2020-05-11T14:15:40Z")

</div>

Hi @spike83,

Where `https_proxy` works, you should be also able of using the `no_proxy` environment variable. You can set this variable to a comma separated list of hosts that shouldn't use proxy.

See the golang docs about this: [https://golang.org/pkg/net/http/#ProxyFromEnvironment](https://golang.org/pkg/net/http/#ProxyFromEnvironment)

---

<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: [May 11, 2020, 2:17pm UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/3 "2020-05-11T14:17:31Z")

</div>

More info here about the values accepted by `no_proxy` [https://godoc.org/golang.org/x/net/http/httpproxy#Config](https://godoc.org/golang.org/x/net/http/httpproxy#Config)

---

<div class="post-metadata">

### Author: ![spike83](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spike83/32/47036_2.png) [@spike83](https://discuss.elastic.co/u/spike83)
#### Post date: [May 12, 2020, 8:54am UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/4 "2020-05-12T08:54:57Z")

</div>

Thank you.

I have sorted my proxy issue out now, but.... I can run the modules test command and connect to my AWS account, but Metricbeat running as a service times out connecting.

[aws.ebs]#011aws/aws.go:93#011failed to list account aliases, please check permission setting: RequestError: send request failed  
metricbeat: caused by: Post [https://iam.amazonaws.com/:](https://iam.amazonaws.com/:) dial tcp 54.239.22.207:443: connect: connection timed out

---

<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: [May 12, 2020, 10:09am UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/5 "2020-05-12T10:09:29Z")

</div>

Umm, this is weird, if `metricbeat test` can connect, then `metricbeat` should be also able to connect. Is it possible that they are being executed with different environment? Do you use some service manager like systemd to run metricbeat?

---

<div class="post-metadata">

### Author: ![spike83](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spike83/32/47036_2.png) [@spike83](https://discuss.elastic.co/u/spike83)
#### Post date: [May 12, 2020, 12:16pm UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/6 "2020-05-12T12:16:58Z")

</div>

Further testing has shown that if I run metricbeat manually with the following parameters

metricbeat -e -d "\*" \>\> log\_file.txt 2\>&1

I can see data being collected and it displays in my dashboard

If I start metricbeat using systemctl it fails to collect the data from aws

---

<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: [May 12, 2020, 1:14pm UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/7 "2020-05-12T13:14:12Z")

</div>

Yeah, this is expected. When you run a service in systemd it starts with a clear environment. If you want to add environment variables you have to add them to the systemd configuration. You can do it for this case by adding a drop-in file, for example in `/etc/systemd/system/metricbeat.service.d/proxy.conf`, with a content like the following one:

```auto
[Service]
Environment="https_proxy=..."
Environment="no_proxy=..."

```

Then `systemctl daemon-reload` and `systemctl restart metricbeat`.

You can read more about customizing Systemd configuration for metricbeat here: [https://www.elastic.co/guide/en/beats/metricbeat/7.6/running-with-systemd.html#\_customize\_systemd\_unit\_for\_metricbeat](https://www.elastic.co/guide/en/beats/metricbeat/7.6/running-with-systemd.html#_customize_systemd_unit_for_metricbeat)

---

<div class="post-metadata">

### Author: ![spike83](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spike83/32/47036_2.png) [@spike83](https://discuss.elastic.co/u/spike83)
#### Post date: [May 12, 2020, 1:18pm UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/8 "2020-05-12T13:18:28Z")

</div>

Thank you Jaime, appreciate the help

---

<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: [June 9, 2020, 1:18pm UTC](https://discuss.elastic.co/t/aws-through-proxy/232022/9 "2020-06-09T13:18:28Z")

</div>

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