# Parsing of field which have dynamic number of subfield

**URL:** <https://discuss.elastic.co/t/parsing-of-field-which-have-dynamic-number-of-subfield/182194>\
**Category:** Logstash\
**Created:** [May 22, 2019, 10:07am UTC](https://discuss.elastic.co/t/parsing-of-field-which-have-dynamic-number-of-subfield/182194 "2019-05-22T10:07:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![swapnali](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@swapnali](https://discuss.elastic.co/u/swapnali)\
**Post date:** [May 22, 2019, 10:07am UTC](https://discuss.elastic.co/t/parsing-of-field-which-have-dynamic-number-of-subfield/182194/1 "2019-05-22T10:07:09Z")

</div>

hi,

I am trying to parse NAS logs,in that i have field "to" in to there are number of receiver address and my logs are streaming logs. so i cant predict how many receiver address will be there in that field

how to parse such kind of data  
below are the value of my field  
\<[a.com](http://a.com)\>,\<[b.com](http://b.com)\>...... so on

thanks

---

<div class="post-metadata">

**Author:** ![logger](https://avatars.discourse-cdn.com/v4/letter/l/34f0e0/32.png) [@logger](https://discuss.elastic.co/u/logger)\
**Post date:** [May 24, 2019, 4:11pm UTC](https://discuss.elastic.co/t/parsing-of-field-which-have-dynamic-number-of-subfield/182194/2 "2019-05-24T16:11:58Z")

</div>

for this we need more detail of the log.

but if these are the values of one field. then you could use the gsub filter and replace the "\<" and "\>" and create an array then elasticsearch will save all values in one field.

[https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-gsub](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-gsub)

and [https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-replace](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-replace)  
to add brackets at the beginning and at the end.  
`mutate { replace => { "field" => "[%{field}]" } }`

---

<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:** [May 24, 2019, 5:17pm UTC](https://discuss.elastic.co/t/parsing-of-field-which-have-dynamic-number-of-subfield/182194/3 "2019-05-24T17:17:43Z")

</div>

You can use [mutate+split](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-split) to convert that to an array.

---

<div class="post-metadata">

**Author:** ![swapnali](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@swapnali](https://discuss.elastic.co/u/swapnali)\
**Post date:** [May 27, 2019, 5:53am UTC](https://discuss.elastic.co/t/parsing-of-field-which-have-dynamic-number-of-subfield/182194/4 "2019-05-27T05:53:39Z")

</div>

Thanks It works  
mutate {  
split =\> {"field\_name" =\> "," }  
}

---

<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:** [June 24, 2019, 5:53am UTC](https://discuss.elastic.co/t/parsing-of-field-which-have-dynamic-number-of-subfield/182194/5 "2019-06-24T05:53:41Z")

</div>

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