# How to adress \[fields\]\[env\] (f.e.) if i want to combine them into a single string

**URL:** https://discuss.elastic.co/t/how-to-adress-fields-env-f-e-if-i-want-to-combine-them-into-a-single-string/223469
**Category:** Logstash
**Created:** [March 13, 2020, 7:58am UTC](https://discuss.elastic.co/t/how-to-adress-fields-env-f-e-if-i-want-to-combine-them-into-a-single-string/223469 "2020-03-13T07:58:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Dennis\_Bohs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dennis_bohs/32/50815_2.png) [@Dennis\_Bohs](https://discuss.elastic.co/u/Dennis_Bohs)
#### Post date: [March 13, 2020, 7:58am UTC](https://discuss.elastic.co/t/how-to-adress-fields-env-f-e-if-i-want-to-combine-them-into-a-single-string/223469/1 "2020-03-13T07:58:21Z")

</div>

Hi there,  
i hope this is a simple question and i just can't find it in the documentation:  
I have several fields, that i'd adress by [fields][something] in logstash.  
Now i want to write an email-alert (with output email) and would like to put the content of those fields into the subject of that mails.  
Now that subject-field accepts a string like add\_fields does aswell, but if i do something like

> subject =\> "%{fields.env} %{fields.loglevel} %{agent.hostname} %{log.file.path}"

it does not replace those tags.  
How would i adress those fields?

---

<div class="post-metadata">

### Author: ![ITIC](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@ITIC](https://discuss.elastic.co/u/ITIC)
#### Post date: [March 13, 2020, 8:18am UTC](https://discuss.elastic.co/t/how-to-adress-fields-env-f-e-if-i-want-to-combine-them-into-a-single-string/223469/2 "2020-03-13T08:18:34Z")

</div>

Hi

The right way is with square brackets:

```auto
subject => "%{[fields][env]} %{[fields][loglevel]} %{[agent][hostname]} %{[log.file][path]}"

```

Hope this helps

---

<div class="post-metadata">

### Author: ![Dennis\_Bohs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dennis_bohs/32/50815_2.png) [@Dennis\_Bohs](https://discuss.elastic.co/u/Dennis_Bohs)
#### Post date: [March 13, 2020, 8:36am UTC](https://discuss.elastic.co/t/how-to-adress-fields-env-f-e-if-i-want-to-combine-them-into-a-single-string/223469/3 "2020-03-13T08:36:36Z")

</div>

yes, this does do the trick. thank you!

---

<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: [April 10, 2020, 8:36am UTC](https://discuss.elastic.co/t/how-to-adress-fields-env-f-e-if-i-want-to-combine-them-into-a-single-string/223469/4 "2020-04-10T08:36:44Z")

</div>

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