# Is it possible to include regex in dissect filter?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-include-regex-in-dissect-filter/138553
**Category:** Logstash
**Created:** [July 4, 2018, 11:50am UTC](https://discuss.elastic.co/t/is-it-possible-to-include-regex-in-dissect-filter/138553 "2018-07-04T11:50:03Z")
**Posts on this page:** 6
**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: [July 4, 2018, 11:50am UTC](https://discuss.elastic.co/t/is-it-possible-to-include-regex-in-dissect-filter/138553/1 "2018-07-04T11:50:03Z")

</div>

Hi,

I am using ELK GA 6.3.0. I am using Logstash to read data from Kafka. I have messages like;

```
 1 0 1707820 142124 198704 511288 0 0 0 144

```

There is a white space at the beginning of message. There are spaces in between, acting as delimiters. The problem is that the number of white space might vary. Sometimes 1, sometimes 2 etc. The number of attributes is constant (10). I was using `grok` filter to split the message like;

```
grok{
	match => { "message" => "%{NUMBER:data1}\s*%{NUMBER:data2}\s*%{NUMBER:data3}\s*%{NUMBER:data4}\s*%{NUMBER:data5}\s*%{NUMBER:data6}\s*%{NUMBER:data7}\s*%{NUMBER:data8}\s*%{NUMBER:data9}\s*%{NUMBER:data10}" }
}

```

I would like to see if this is possible with `dissect` filter. I have tried;

```
dissect{
	mapping => { "message" => "%{data1}\s*%{data2}\s*%{data3}\s*%{data4}\s*%{data5}\s*%{data6}\s*%{data7}\s*%{data8}\s*%{data9}\s*%{data10}" }
}

```

But this is not working. Is this possible?

Thanks.

---

<div class="post-metadata">

### Author: ![Charaf\_Ahmed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/charaf_ahmed/32/30467_2.png) [@Charaf\_Ahmed](https://discuss.elastic.co/u/Charaf_Ahmed)
#### Post date: [July 4, 2018, 11:54am UTC](https://discuss.elastic.co/t/is-it-possible-to-include-regex-in-dissect-filter/138553/2 "2018-07-04T11:54:49Z")

</div>

I do not think the number of spaces can vary.  
Personally, I often use : [http://grokconstructor.appspot.com/](http://grokconstructor.appspot.com/)

---

<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: [July 4, 2018, 12:15pm UTC](https://discuss.elastic.co/t/is-it-possible-to-include-regex-in-dissect-filter/138553/3 "2018-07-04T12:15:24Z")

</div>

You need to use the `->` notation to handle varying number of separators. See [the docs](https://www.elastic.co/guide/en/logstash/current/plugins-filters-dissect.html#_delimiters_used_as_padding_to_visually_align_fields) for an example of the syntax.

---

<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: [July 4, 2018, 3:07pm UTC](https://discuss.elastic.co/t/is-it-possible-to-include-regex-in-dissect-filter/138553/4 "2018-07-04T15:07:53Z")

</div>

Ok, I understand, (and I had already gone through that 😉) But what if my data is like `0\t 2`?

Tried `%{data1}\t %{data2}` and it gave data1 `""` and data2 `"0\t 2"`.

Tried `%{data1} %{data2}` and it gave data1 `"0\t"` and data2 `"2"`.

Is there any way to fix this?

---

<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: [July 4, 2018, 3:46pm UTC](https://discuss.elastic.co/t/is-it-possible-to-include-regex-in-dissect-filter/138553/5 "2018-07-04T15:46:03Z")

</div>

Then you might be better off using grok with the SPACE pattern.

---

<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: [August 1, 2018, 3:46pm UTC](https://discuss.elastic.co/t/is-it-possible-to-include-regex-in-dissect-filter/138553/6 "2018-08-01T15:46:50Z")

</div>

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