# Journalbeat: Environment variable in config crashes service

**URL:** https://discuss.elastic.co/t/journalbeat-environment-variable-in-config-crashes-service/249091
**Category:** Beats
**Tags:** journalbeat
**Created:** [September 18, 2020, 11:45am UTC](https://discuss.elastic.co/t/journalbeat-environment-variable-in-config-crashes-service/249091 "2020-09-18T11:45:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alpi-ua](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alpi-ua/32/75818_2.png) [@alpi-ua](https://discuss.elastic.co/u/alpi-ua)
#### Post date: [September 18, 2020, 11:45am UTC](https://discuss.elastic.co/t/journalbeat-environment-variable-in-config-crashes-service/249091/1 "2020-09-18T11:45:18Z")

</div>

Hello.  
Please, help with the issue.  
Following this [reference](https://www.elastic.co/guide/en/beats/journalbeat/7.9/using-environ-vars.html), I've added following to my config:

```yml
fields_under_root: true
fields:
   hwkey: ${HWKEY}

```

And after restarting the service, constantly receiving:  
`systemctl restart jounalbeat && systemctl status journalbeat`

> ExecStart=/usr/share/journalbeat/bin/journalbeat --environment systemd $BEAT\_LOG\_OPTS $BEAT\_CONFIG\_OPTS $BEAT\_PATH\_OPTS (code=exited, status=1/FAILURE)  
> Main PID: 5032 (code=exited, status=1/FAILURE)

If i run jb manually from command prompt,

```auto
journalbeat --environment systemd -c /etc/journalbeat/journalbeat.yml --path.home /usr/share/journalbeat --path.config /etc/journalbeat --path.data /var/lib/journalbeat --path.logs /var/log/journalbeat

```

everything works like a charm, and my variable is expanding like expected.

config passes the test:  
` journalbeat -c /etc/journalbeat/journalbeat.yml test config`

> Config OK

I'm running Journalbeat 7.9, and getting the samo on Suse 42.2 x64 (4.4.27-2-default) and Ubuntu 18.04 x64 (4.15.0-64-generic)

Any ideas ?

---

<div class="post-metadata">

### Author: ![Alex\_Kristiansen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_kristiansen/32/46086_2.png) [@Alex\_Kristiansen](https://discuss.elastic.co/u/Alex_Kristiansen)
#### Post date: [September 18, 2020, 4:16pm UTC](https://discuss.elastic.co/t/journalbeat-environment-variable-in-config-crashes-service/249091/2 "2020-09-18T16:16:33Z")

</div>

@alpi-ua,

Are there any logs from journalbeat in the system log?

---

<div class="post-metadata">

### Author: ![alpi-ua](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alpi-ua/32/75818_2.png) [@alpi-ua](https://discuss.elastic.co/u/alpi-ua)
#### Post date: [September 20, 2020, 9:20pm UTC](https://discuss.elastic.co/t/journalbeat-environment-variable-in-config-crashes-service/249091/3 "2020-09-20T21:20:31Z")

</div>

It was this

> Exiting: error unpacking config data: missing field accessing 'fields.hwkey' (source:'/etc/journalbeat/journalbeat.yml')

I put variable to the /etc/systemd/system/journalbeat.service.d/override.conf and it seems to work fine now.

---

<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 18, 2020, 11:20pm UTC](https://discuss.elastic.co/t/journalbeat-environment-variable-in-config-crashes-service/249091/4 "2020-10-18T23:20:48Z")

</div>

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