# Grok with multiple square brackerts

**URL:** <https://discuss.elastic.co/t/grok-with-multiple-square-brackerts/127589>\
**Category:** Logstash\
**Created:** [April 11, 2018, 8:28am UTC](https://discuss.elastic.co/t/grok-with-multiple-square-brackerts/127589 "2018-04-11T08:28:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxc654951](https://avatars.discourse-cdn.com/v4/letter/z/c89c15/32.png) [@zxc654951](https://discuss.elastic.co/u/zxc654951)\
**Post date:** [April 11, 2018, 8:28am UTC](https://discuss.elastic.co/t/grok-with-multiple-square-brackerts/127589/1 "2018-04-11T08:28:12Z")

</div>

hello,

I had a log with multiple square brackets like below：  
[info 2018/04/11 23:59:59.999999 ABC ABCDEX:99999 123456789876543] IO error[000] installed ... ... ...[ABCDEX:90909]: ...::... failed with errno: 000: ... ...

I try to use grok debugger and the result isn't as my wish. Here is my config:  
[%{GREEDYDATA:data\_temp}] %{GREEDYDATA:detail}

And result:  
{  
"data\_temp": [  
[  
"info 2018/04/11 23:59:59.999999 ABC ABCDEX:99999 123456789876543] IO error[000"  
]  
],  
"detail": [  
[  
"installed ... ... ...[ABCDEX:90909]: ...::... failed with errno: 000: ... ..."  
]  
]  
}

But I want to get the result like below:  
{  
"data\_temp": [  
[  
"info 2018/04/11 23:59:59.999999 ABC ABCDEX:99999 123456789876543"  
]  
],  
"detail": [  
[  
"IO error[000] installed ... ... ...[ABCDEX:90909]: ...::... failed with errno: 000: ... ..."  
]  
]  
}

Can someone tell me where going wrong?  
Thanks.

Regards,  
zxc654951

---

<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:** [April 11, 2018, 8:49am UTC](https://discuss.elastic.co/t/grok-with-multiple-square-brackerts/127589/2 "2018-04-11T08:49:11Z")

</div>

DATA should work better than GREEDYDATA, but even better is to use neither. Use `(?<name-of-field>[^\]]*)` to match and capture zero or more characters or any kind **except** `]`. That's more efficient.

---

<div class="post-metadata">

**Author:** ![zxc654951](https://avatars.discourse-cdn.com/v4/letter/z/c89c15/32.png) [@zxc654951](https://discuss.elastic.co/u/zxc654951)\
**Post date:** [April 11, 2018, 8:52am UTC](https://discuss.elastic.co/t/grok-with-multiple-square-brackerts/127589/3 "2018-04-11T08:52:27Z")

</div>

It works. Thank you.

---

<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, 8:52am UTC](https://discuss.elastic.co/t/grok-with-multiple-square-brackerts/127589/4 "2018-05-09T08:52:41Z")

</div>

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