# Is it possible to use enviromant variable in config for user

**URL:** https://discuss.elastic.co/t/is-it-possible-to-use-enviromant-variable-in-config-for-user/205964
**Category:** Beats
**Tags:** metricbeat
**Created:** [October 31, 2019, 2:23am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-enviromant-variable-in-config-for-user/205964 "2019-10-31T02:23:03Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![chersko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chersko/32/46457_2.png) [@chersko](https://discuss.elastic.co/u/chersko)
#### Post date: [October 31, 2019, 2:23am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-enviromant-variable-in-config-for-user/205964/1 "2019-10-31T02:23:03Z")

</div>

is possible to use a enviroment variable in the config for the user  
for example  
// cloud.auth: '{metrics\_uname}:{MW\_PWD}'

---

<div class="post-metadata">

### Author: ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)
#### Post date: [October 31, 2019, 7:53am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-enviromant-variable-in-config-for-user/205964/2 "2019-10-31T07:53:42Z")

</div>

Yes. See more: [https://www.elastic.co/guide/en/beats/metricbeat/current/using-environ-vars.html](https://www.elastic.co/guide/en/beats/metricbeat/current/using-environ-vars.html)

---

<div class="post-metadata">

### Author: ![chersko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chersko/32/46457_2.png) [@chersko](https://discuss.elastic.co/u/chersko)
#### Post date: [October 31, 2019, 2:14pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-enviromant-variable-in-config-for-user/205964/3 "2019-10-31T14:14:55Z")

</div>

thanks i sew that before declared my variable in /etc/environment  
my config is at follows  
cloud.auth: '{metrics\_uname}:{MW\_PWD}'  
"metrics\_uname" being a variable daclared in /etc/environment and MW\_PWD a key store variable  
but i receive the following error  
Oct 31 09:13:07 logstash metricbeat[13830]: 2019-10-31T09:13:07.261-0500 ERROR instance/beat.go:878 Exiting: missing field accessing 'username' (source:'/etc/metricbeat/metricbeat.yml') Oct 31 09:13:07 logstash metricbeat[13830]: Exiting: missing field accessing 'username' (source:'/etc/metricbeat/metricbeat.yml')  
Oct 31 09:13:07 logstash systemd[1]: metricbeat.service: Main process exited, code=exited, status=1/FAILURE  
Oct 31 09:13:07 logstash systemd[1]: metricbeat.service: Failed with result 'exit-code'.  
Oct 31 09:13:07 logstash systemd[1]: metricbeat.service: Service hold-off time over, scheduling restart.  
Oct 31 09:13:07 logstash systemd[1]: metricbeat.service: Scheduled restart job, restart counter is at 5.  
Oct 31 09:13:07 logstash systemd[1]: Stopped Metricbeat is a lightweight shipper for metrics..  
Oct 31 09:13:07 logstash systemd[1]: metricbeat.service: Start request repeated too quickly.  
Oct 31 09:13:07 logstash systemd[1]: metricbeat.service: Failed with result 'exit-code'.  
Oct 31 09:13:07 logstash systemd[1]: Failed to start Metricbeat is a lightweight shipper for metrics..

---

<div class="post-metadata">

### Author: ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)
#### Post date: [October 31, 2019, 3:58pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-enviromant-variable-in-config-for-user/205964/4 "2019-10-31T15:58:30Z")

</div>

`$` is missing from your configuration. `cloud.auth: '${metrics_uname}` is the correct config.

What is `MW_PWD`? Is this also an env variable?

---

<div class="post-metadata">

### Author: ![chersko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chersko/32/46457_2.png) [@chersko](https://discuss.elastic.co/u/chersko)
#### Post date: [November 1, 2019, 1:40am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-enviromant-variable-in-config-for-user/205964/5 "2019-11-01T01:40:21Z")

</div>

sorry was a mistake in the post in the config i have it with `$` and it's not working `MW_PWD` is a metricbeat keystore key value pair

---

<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: [November 29, 2019, 1:40am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-enviromant-variable-in-config-for-user/205964/6 "2019-11-29T01:40:25Z")

</div>

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