# Split message logstash elasticsearch

**URL:** <https://discuss.elastic.co/t/split-message-logstash-elasticsearch/296291>\
**Category:** Logstash\
**Created:** [February 4, 2022, 12:50pm UTC](https://discuss.elastic.co/t/split-message-logstash-elasticsearch/296291 "2022-02-04T12:50:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_vermex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_vermex/32/101267_2.png) [@alex\_vermex](https://discuss.elastic.co/u/alex_vermex)\
**Post date:** [February 4, 2022, 12:50pm UTC](https://discuss.elastic.co/t/split-message-logstash-elasticsearch/296291/1 "2022-02-04T12:50:37Z")

</div>

Hi,  
my message it looks like :

 ![e](https://us1.discourse-cdn.com/elastic/original/3X/6/2/6239fd6e4c2acd0aa9b2eb2d2e1ca4545450a5cf.png)  
i want to add field when found the "|" it means to split it with "|"  
i did it but it looks with a wrong method :  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/7/a799c5d59a34d919f6794ebc5de654bc13f246f3.png)  
imagine that we have a lot of data in one message and in the same file there is a lot of data but it's not the same format ...  
So i want to add field when i found "|"

Any help would be sincerely appreciate!  
Thanks!

---

<div class="post-metadata">

**Author:** ![Matiasinco](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matiasinco/32/101548_2.png) [@Matiasinco](https://discuss.elastic.co/u/Matiasinco)\
**Post date:** [February 8, 2022, 6:45pm UTC](https://discuss.elastic.co/t/split-message-logstash-elasticsearch/296291/2 "2022-02-08T18:45:59Z")

</div>

I'm in a very similar scenario, but in my case I want to split when I found ", @" this 3 characters.  
Is basically a login of Stored procedures with parameters. So I want to split the parameter column into different fields. Please let me know if you found the way for this. Also to do it dinamically I guess only with ruby is possible

---

<div class="post-metadata">

**Author:** ![alex\_vermex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex_vermex/32/101267_2.png) [@alex\_vermex](https://discuss.elastic.co/u/alex_vermex)\
**Post date:** [February 8, 2022, 7:28pm UTC](https://discuss.elastic.co/t/split-message-logstash-elasticsearch/296291/3 "2022-02-08T19:28:33Z")

</div>

I found somthing i think it's better:

```auto
filter {

    mutate {

      split => {"message" => "|"}

      add_field => { "field_name1" => "%{[message][0]}" }

      add_field => { "field_name" => "%{[message][1]}" }

      add_field => { "field_name2" => "%{[message][2]}" }
}
}

```

---

<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:** [March 8, 2022, 7:28pm UTC](https://discuss.elastic.co/t/split-message-logstash-elasticsearch/296291/4 "2022-03-08T19:28:40Z")

</div>

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