# Use Environment Variables in properties File

**URL:** <https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758>\
**Category:** APM\
**Tags:** java\
**Created:** [May 13, 2019, 8:33am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758 "2019-05-13T08:33:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [May 13, 2019, 8:33am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/1 "2019-05-13T08:33:17Z")

</div>

Is it possible to use Windows Environment Variables in the config file.

eg. service\_name=Servicename\_%Hostname%

Thx

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [May 13, 2019, 11:11am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/2 "2019-05-13T11:11:59Z")

</div>

Are you referring to the APM Server config file or one of the agents?

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [May 13, 2019, 11:13am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/3 "2019-05-13T11:13:58Z")

</div>

Agent properties File.

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [May 13, 2019, 11:28am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/4 "2019-05-13T11:28:33Z")

</div>

Which agent are you using?

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [May 13, 2019, 11:47am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/5 "2019-05-13T11:47:14Z")

</div>

Java Agent 1.6.1

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [May 13, 2019, 6:40pm UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/6 "2019-05-13T18:40:20Z")

</div>

Not in the config file, as it will be read and parsed as a string.  
For that you will need to set this configuration via environment variable or system property.

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [May 14, 2019, 4:50am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/7 "2019-05-14T04:50:12Z")

</div>

Hi @Eyal_Koren! Thanks for the answer. So I can set some of my settings in the config file and some others via environment variable or system property?

Then I will set only this one via env and hope it works 😃

Thx

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [May 21, 2019, 11:51am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/8 "2019-05-21T11:51:26Z")

</div>

> [@gruselglatz](#):
>
> So I can set some of my settings in the config file and some others via environment variable or system property?

Yes, that should work. Did it work for you?

---

<div class="post-metadata">

**Author:** ![gruselglatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gruselglatz/32/42675_2.png) [@gruselglatz](https://discuss.elastic.co/u/gruselglatz)\
**Post date:** [May 21, 2019, 12:13pm UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/9 "2019-05-21T12:13:11Z")

</div>

@felixbarny I didn't try it now, but when I have Time, maybe next week or so, i will try it.

---

<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 11, 2019, 8:13am UTC](https://discuss.elastic.co/t/use-environment-variables-in-properties-file/180758/10 "2019-06-11T08:13:14Z")

</div>

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