# Grok comma separated text

**URL:** <https://discuss.elastic.co/t/grok-comma-separated-text/145186>\
**Category:** Logstash\
**Created:** [August 20, 2018, 2:12pm UTC](https://discuss.elastic.co/t/grok-comma-separated-text/145186 "2018-08-20T14:12:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcusCaepio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcuscaepio/32/32458_2.png) [@MarcusCaepio](https://discuss.elastic.co/u/MarcusCaepio)\
**Post date:** [August 20, 2018, 2:13pm UTC](https://discuss.elastic.co/t/grok-comma-separated-text/145186/1 "2018-08-20T14:13:00Z")

</div>

Hi all,  
I want to grok a message like

blablabla: entry\_1, entry\_2, entry\_3

the message has at least 1 entry after the : and CAN HAVE up to x entries, which are separated with ",".  
I need a grok which matches the first entry and also matches every optionally entry, separated by a "," all assigned to the field "entries".

Thanks in advance

EDIT: in Rubular it would be just like

([\w]+)

But I cannot figure out how to use this in grok

---

<div class="post-metadata">

**Author:** ![\_Alex](https://avatars.discourse-cdn.com/v4/letter/_/54ee81/32.png) [@\_Alex](https://discuss.elastic.co/u/_Alex)\
**Post date:** [August 20, 2018, 3:22pm UTC](https://discuss.elastic.co/t/grok-comma-separated-text/145186/2 "2018-08-20T15:22:29Z")

</div>

I would do this in two steps. First split out the key `blablabla` and the csv data, and then split the data into an array.

```
filter {
  grok {
    match => { "message" => "[^:]*: %{GREEDYDATA:mycsvdata}"}
  }
  mutate {
    split => {"mycsvdata" => "," }
  }
}

```

This will result in:

```
"mycsvdata":["entry_1"," entry_2"," entry_3"]
```

---

<div class="post-metadata">

**Author:** ![MarcusCaepio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcuscaepio/32/32458_2.png) [@MarcusCaepio](https://discuss.elastic.co/u/MarcusCaepio)\
**Post date:** [August 20, 2018, 3:26pm UTC](https://discuss.elastic.co/t/grok-comma-separated-text/145186/3 "2018-08-20T15:26:33Z")

</div>

is there no way with grok? this line is a part of a pattern and my filter consists of many many patterns. so I have to split this line in the pattern itself.

---

<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 17, 2018, 3:26pm UTC](https://discuss.elastic.co/t/grok-comma-separated-text/145186/4 "2018-09-17T15:26:44Z")

</div>

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