# Using environment variable to specify file paths in yml config file

**URL:** <https://discuss.elastic.co/t/using-environment-variable-to-specify-file-paths-in-yml-config-file/103328>\
**Category:** Beats\
**Created:** [October 10, 2017, 9:19am UTC](https://discuss.elastic.co/t/using-environment-variable-to-specify-file-paths-in-yml-config-file/103328 "2017-10-10T09:19:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdanner](https://avatars.discourse-cdn.com/v4/letter/m/76d3ee/32.png) [@mdanner](https://discuss.elastic.co/u/mdanner)\
**Post date:** [October 10, 2017, 9:19am UTC](https://discuss.elastic.co/t/using-environment-variable-to-specify-file-paths-in-yml-config-file/103328/1 "2017-10-10T09:19:45Z")

</div>

Is it possible to use an environment variable to specify part of the file path in the \*beat.yml configuration?

You can see what I'm trying to do here. Is there a way to make it work?

```
output.logstash:
  hosts: ["foobar.com:5044"]
  ssl.certificate_authorities: ['${%PROGRAMFILES(X86)}\Metricbeat\pki\ca.crt']
  ssl.certificate: '${%PROGRAMFILES(X86)}\Metricbeat\pki\metricbeat-client.crt'
  ssl.key: '${%PROGRAMFILES(X86)}\Metricbeat\pki\metricbeat-client.key'
```

---

<div class="post-metadata">

**Author:** ![mdanner](https://avatars.discourse-cdn.com/v4/letter/m/76d3ee/32.png) [@mdanner](https://discuss.elastic.co/u/mdanner)\
**Post date:** [October 10, 2017, 9:28am UTC](https://discuss.elastic.co/t/using-environment-variable-to-specify-file-paths-in-yml-config-file/103328/2 "2017-10-10T09:28:23Z")

</div>

I spotted the error as soon as I posted this topic. The environment variables contain a % that shouldn't be there. This works just fine:

```
output.logstash:
  hosts: ["foobar.com:5044"]
  ssl.certificate_authorities: ['${PROGRAMFILES(X86)}\Metricbeat\pki\ca.crt']
  ssl.certificate: '${PROGRAMFILES(X86)}\Metricbeat\pki\metricbeat-client.crt'
  ssl.key: '${PROGRAMFILES(X86)}\Metricbeat\pki\metricbeat-client.key'

```

The ability to embed environment variables is a cool feature!

---

<div class="post-metadata">

**Author:** ![ruflin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ruflin/32/3116_2.png) [@ruflin](https://discuss.elastic.co/u/ruflin)\
**Post date:** [October 10, 2017, 11:17am UTC](https://discuss.elastic.co/t/using-environment-variable-to-specify-file-paths-in-yml-config-file/103328/3 "2017-10-10T11:17:38Z")

</div>

Glad you found the solution and thanks for posting it for others.

---

<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:** [October 31, 2017, 9:19am UTC](https://discuss.elastic.co/t/using-environment-variable-to-specify-file-paths-in-yml-config-file/103328/4 "2017-10-31T09:19:53Z")

</div>

This topic was automatically closed after 21 days. New replies are no longer allowed.
