# Is it possible to substitute the value of a field from env variable in logstash

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-substitute-the-value-of-a-field-from-env-variable-in-logstash/71510>\
**Category:** Logstash\
**Created:** [January 13, 2017, 10:37am UTC](https://discuss.elastic.co/t/is-it-possible-to-substitute-the-value-of-a-field-from-env-variable-in-logstash/71510 "2017-01-13T10:37:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![G.S](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@G.S](https://discuss.elastic.co/u/G.S)\
**Post date:** [January 13, 2017, 10:37am UTC](https://discuss.elastic.co/t/is-it-possible-to-substitute-the-value-of-a-field-from-env-variable-in-logstash/71510/1 "2017-01-13T10:37:38Z")

</div>

Hi,  
I am using logstash-2.3.4. In my case, input file contains the ID of the operation, which I need to translate it to its name in the output. For example:  
**Input:**

> 1,SUCCESS  
> 2,SUCCESS  
> 3,ERROR

Let's assume the numbers are operation IDs and `1=create, 2=update, 3=delete` and added them in environment variable.

After matching the grok pattern, is there any way that I can directly substitute the values for the operation so that they are translated to their name.

Something like `${%{operation_id}}` and it appears are `create` for 1 - where `%{operation_id}` is matched from grok.  
I tried the way as I mentioned above but it appears as `${1}` in the output.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 13, 2017, 12:31pm UTC](https://discuss.elastic.co/t/is-it-possible-to-substitute-the-value-of-a-field-from-env-variable-in-logstash/71510/2 "2017-01-13T12:31:45Z")

</div>

Does it have to be an environment variable? Your use case sounds like a good fit for the translate filter.

---

<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:** [February 10, 2017, 12:32pm UTC](https://discuss.elastic.co/t/is-it-possible-to-substitute-the-value-of-a-field-from-env-variable-in-logstash/71510/3 "2017-02-10T12:32:37Z")

</div>

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