# Logstash 6.2.3 filter/mutate/spit quandry

**URL:** <https://discuss.elastic.co/t/logstash-6-2-3-filter-mutate-spit-quandry/125988>\
**Category:** Logstash\
**Created:** [March 28, 2018, 6:42pm UTC](https://discuss.elastic.co/t/logstash-6-2-3-filter-mutate-spit-quandry/125988 "2018-03-28T18:42:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davehatma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davehatma/32/29322_2.png) [@davehatma](https://discuss.elastic.co/u/davehatma)\
**Post date:** [March 28, 2018, 6:42pm UTC](https://discuss.elastic.co/t/logstash-6-2-3-filter-mutate-spit-quandry/125988/1 "2018-03-28T18:42:00Z")

</div>

So, I'm scratching my head here. After exhaustive Googling I just don't know why this apparently simple function isn't working for me. Here is the filter/mutate code.

> ```
> mutate {
> add_field => {"temp" => "poc-pymsa-exceptions-log"}
> split => {"temp" => "-"}
> }  
> 
> ```

Using the output ruby codec, I get the following value for temp:

> "temp" =\> "poc-pymsa-exceptions-log",

According to the 6.2 [documentation](https://www.elastic.co/guide/en/logstash/5.6/plugins-filters-mutate.html#plugins-filters-mutate-split), the "temp" field should be converted to an array : ['poc', 'pymsa', 'exceptions', 'log'] AND I should be able to access the array elements [temp][0] or [temp][2].

But its just not working. Any help is most appreciated  
Thanks,

Dave Howell

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [March 29, 2018, 12:04am UTC](https://discuss.elastic.co/t/logstash-6-2-3-filter-mutate-spit-quandry/125988/2 "2018-03-29T00:04:06Z")

</div>

This is because LS only executes the `add_field`, `remove_field`, `add_tag` and `remove_tag` operations as the last thing a filter does to a given event. That is, the filters primary operations occur before the `add|remove_field|tag` operations (internally we call them `decorations`).

The reasoning here is that many filters have a conditional execution of decorations such that fields tags are only manipulated on successful execution of the filters main operation. Think grok, date, dissect, kv etc. However, as mutate is a multifunctional filter, there is no notion of overall success and so it executes the decorate functions unconditionally, but at the end.

---

<div class="post-metadata">

**Author:** ![davehatma](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davehatma/32/29322_2.png) [@davehatma](https://discuss.elastic.co/u/davehatma)\
**Post date:** [April 11, 2018, 3:25pm UTC](https://discuss.elastic.co/t/logstash-6-2-3-filter-mutate-spit-quandry/125988/3 "2018-04-11T15:25:05Z")

</div>

Guy, Indeed that was it. Thanks for pointing that out. I have adjusted. Regards.

---

<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:** [May 9, 2018, 3:25pm UTC](https://discuss.elastic.co/t/logstash-6-2-3-filter-mutate-spit-quandry/125988/4 "2018-05-09T15:25:12Z")

</div>

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