# How to create fields dynamically?

**URL:** <https://discuss.elastic.co/t/how-to-create-fields-dynamically/249115>\
**Category:** Logstash\
**Created:** [September 18, 2020, 2:19pm UTC](https://discuss.elastic.co/t/how-to-create-fields-dynamically/249115 "2020-09-18T14:19:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11191](https://avatars.discourse-cdn.com/v4/letter/1/9dc877/32.png) [@11191](https://discuss.elastic.co/u/11191)\
**Post date:** [September 18, 2020, 2:19pm UTC](https://discuss.elastic.co/t/how-to-create-fields-dynamically/249115/1 "2020-09-18T14:19:07Z")

</div>

I have a log looking like:

`[2020-09-18 12:34 smth1=38 smth2=125 ...]`

and I want "smth1" to be a field name and "38" its value, what would be best way to do it considering that "smth1" might be different each time?

`%{TIMESTAMP_ISO8601:time}%{SPACE}smth1=%{NUMBER:smth1:float}` would be hardcoded way I want to avoid.

---

<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:** [September 18, 2020, 3:14pm UTC](https://discuss.elastic.co/t/how-to-create-fields-dynamically/249115/2 "2020-09-18T15:14:17Z")

</div>

Use a dissect filter to take off the date, then use a kv filter.

```
dissect { mapping => { "message" => [%{timestamp} %{+timestamp} %{restOfLine}" } }
kv { source => "restOfLine" }
```

---

<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 16, 2020, 3:14pm UTC](https://discuss.elastic.co/t/how-to-create-fields-dynamically/249115/3 "2020-10-16T15:14:19Z")

</div>

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