# Is it possible to use split filter instead of grok in Logstash to chop message?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878
**Category:** Logstash
**Created:** [June 21, 2018, 1:32pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878 "2018-06-21T13:32:03Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)
#### Post date: [June 21, 2018, 1:32pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878/1 "2018-06-21T13:32:03Z")

</div>

Hi,

I am using ELK GA 6.3. I am using Logstash to read data from Kafka. My Kafka message is like;

```
<Jun 02, 2018 12:04:41:531 AM> <data1> <data2> <data3\n>

```

I am using the below grok pattern to split data;

```
grok {
	match => { "message" => "<%{GREEDYDATA:timestamp}> <%{GREEDYDATA:data1}> <%{GREEDYDATA:data2}> <%{GREEDYDATA:data3}>" }
}

```

is it possible to achieve the same using `split` filter?

Thank you.

---

<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: [June 21, 2018, 1:38pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878/2 "2018-06-21T13:38:07Z")

</div>

The split filter splits a single message into multiple messages so it's not equivalent to what you get with a grok filter.

Don't use multiple GREEEDYDATA like that. It's very ineffecient and could easily match things incorrectly.

---

<div class="post-metadata">

### Author: ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)
#### Post date: [June 21, 2018, 1:43pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878/3 "2018-06-21T13:43:20Z")

</div>

@magnusbaeck why I am using GREEEDYDATA there is because;

1. `GREEDYDATA .*`. Greedydata matches everything. I want everything inside `<` and `>`, and I dont want to perform validation. I believe that `.*` takes less effort compared to others.
2. My entire message is inside `<tags>` so that I have a start point `<` and end point `>` for messages.

Is this okay / still inefficient?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [June 21, 2018, 1:46pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878/4 "2018-06-21T13:46:55Z")

</div>

As you have well defined field separators, the [dissect filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-dissect.html) might be a good and efficient option here.

---

<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: [June 21, 2018, 1:48pm UTC](https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878/5 "2018-06-21T13:48:26Z")

</div>

It's still inefficient since it's greedy and will first attempt to stuff `<data1> <data2> <data3>` into the `data1` field, but then it discovers that there's no text left for the two GREEDYDATA pattern to match against, so it backtracks and tries to match `<data1> <data2>` but then there's still one GREEDYDATA that doesn't get anything so... you get the idea.

Using DATA should be much more efficient, but I'd still expect it to be outperformed by `(?<data1>[^>]+)`.

---

<div class="post-metadata">

### Author: ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)
#### Post date: [June 22, 2018, 4:36am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878/6 "2018-06-22T04:36:57Z")

</div>

Oh 😮 ok ok.. now i understand..

---

<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: [July 20, 2018, 4:36am UTC](https://discuss.elastic.co/t/is-it-possible-to-use-split-filter-instead-of-grok-in-logstash-to-chop-message/136878/7 "2018-07-20T04:36:59Z")

</div>

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