# How to add a new field and value with field name and value taken from another fields value?

**URL:** <https://discuss.elastic.co/t/how-to-add-a-new-field-and-value-with-field-name-and-value-taken-from-another-fields-value/163368>\
**Category:** Logstash\
**Created:** [January 8, 2019, 1:25pm UTC](https://discuss.elastic.co/t/how-to-add-a-new-field-and-value-with-field-name-and-value-taken-from-another-fields-value/163368 "2019-01-08T13:25:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hpniemitube](https://avatars.discourse-cdn.com/v4/letter/h/ce7236/32.png) [@hpniemitube](https://discuss.elastic.co/u/hpniemitube)\
**Post date:** [January 8, 2019, 1:25pm UTC](https://discuss.elastic.co/t/how-to-add-a-new-field-and-value-with-field-name-and-value-taken-from-another-fields-value/163368/1 "2019-01-08T13:25:04Z")

</div>

I would like to know how I could do this kind of new field:

- Field "sesssion.variable\_name" exists and has a value for example "session.username"
- Field "session.variable\_value" exists and has a value for example "Mike"

How could I add a new field and name it by taking the value of the field "sesssion.variable\_name" and then adding a value to that new field from the field "session.variable\_value"?

So the ending should be a field-value pair "session.username=Mike".

Thanks.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 8, 2019, 2:17pm UTC](https://discuss.elastic.co/t/how-to-add-a-new-field-and-value-with-field-name-and-value-taken-from-another-fields-value/163368/2 "2019-01-08T14:17:23Z")

</div>

```
filter { mutate { add_field => { "%{session.variable_name}" => "%{session.variable_value}" } } }
```

---

<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 5, 2019, 2:17pm UTC](https://discuss.elastic.co/t/how-to-add-a-new-field-and-value-with-field-name-and-value-taken-from-another-fields-value/163368/3 "2019-02-05T14:17:35Z")

</div>

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