# Picking substring from field in logstash

**URL:** <https://discuss.elastic.co/t/picking-substring-from-field-in-logstash/97797>\
**Category:** Logstash\
**Created:** [August 21, 2017, 4:13pm UTC](https://discuss.elastic.co/t/picking-substring-from-field-in-logstash/97797 "2017-08-21T16:13:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek\_Sharma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_sharma/32/46948_2.png) [@Vivek\_Sharma](https://discuss.elastic.co/u/Vivek_Sharma)\
**Post date:** [August 21, 2017, 4:13pm UTC](https://discuss.elastic.co/t/picking-substring-from-field-in-logstash/97797/1 "2017-08-21T16:13:30Z")

</div>

Hi

I have a log field in the pattern: PRODUCT\_GLOBAL\_20170706024756466\_0000000004069390

My requirement is to extract 0000000004069390 from the field and store it in a new field named FieldX.

Can anyone please help me in guiding how can I extract sub string from the log.

I tried using split in mutate but it is not working.  
split =\> { "parsedIDocList._id" =\> "_" }

Thanks

---

<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:** [August 23, 2017, 8:47pm UTC](https://discuss.elastic.co/t/picking-substring-from-field-in-logstash/97797/2 "2017-08-23T20:47:19Z")

</div>

**Always** post logs and configuration as preformatted text. I have adjusted your configuration snippet to reflect what I think your actual configuration is.

> I tried using split in mutate but it is not working.
> 
> ```
> split => { "parsedIDocList.id" => "_" }
> 
> ```

That's not the correct syntax for nested fields, see [Accessing event data and fields | Logstash Reference [8.11] | Elastic](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references).

You could also consider using a grok filter, although I'd expect it to be less performant that a split 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:** [September 20, 2017, 8:47pm UTC](https://discuss.elastic.co/t/picking-substring-from-field-in-logstash/97797/3 "2017-09-20T20:47:32Z")

</div>

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