# How to group space-separated parts of a message into one field in Grok?

**URL:** <https://discuss.elastic.co/t/how-to-group-space-separated-parts-of-a-message-into-one-field-in-grok/77181>\
**Category:** Logstash\
**Created:** [March 2, 2017, 4:49pm UTC](https://discuss.elastic.co/t/how-to-group-space-separated-parts-of-a-message-into-one-field-in-grok/77181 "2017-03-02T16:49:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZillaG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zillag/32/10505_2.png) [@ZillaG](https://discuss.elastic.co/u/ZillaG)\
**Post date:** [March 2, 2017, 4:49pm UTC](https://discuss.elastic.co/t/how-to-group-space-separated-parts-of-a-message-into-one-field-in-grok/77181/1 "2017-03-02T16:49:59Z")

</div>

I have this log message

```
2017-03-02 15:52:08,455 INFO :RMI TCP Connection(80920)-10.53.123.123 [c
    om.company.app] Hello world

```

I want to group the "RMI TCP onnection(80920)-10.53.123.123" into one field, called my\_connection, so my grok filter looks like this

```
filter {
  grok {
    match => {
      "message" => [
          "%{TIMESTAMP_ISO8601:logdate}%{SPACE}%{LOGLEVEL:loglevel}%{SPACE}:(?<my_connection>???) ......"
      ]
    }
  }
}

```

What should the ??? be?

---

<div class="post-metadata">

**Author:** ![ZillaG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zillag/32/10505_2.png) [@ZillaG](https://discuss.elastic.co/u/ZillaG)\
**Post date:** [March 2, 2017, 5:29pm UTC](https://discuss.elastic.co/t/how-to-group-space-separated-parts-of-a-message-into-one-field-in-grok/77181/2 "2017-03-02T17:29:41Z")

</div>

I came up with the following. However, it includes the space before the open square bracket before the classname. How do I rid of the space?

`(?<node_connection>[^\[]*)`

In other words, I get (space after the last 123 octet)

`node_connection = "RMI TCP Connection(80920)-10.53.123.123 "`

but I want (no space after last 123 octet)

`node_connection = "RMI TCP Connection(80920)-10.53.123.123"`

---

<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:** [March 7, 2017, 6:24am UTC](https://discuss.elastic.co/t/how-to-group-space-separated-parts-of-a-message-into-one-field-in-grok/77181/3 "2017-03-07T06:24:58Z")

</div>

Just make sure there's a space _after_ the closing parenthesis.

---

<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:** [April 4, 2017, 6:25am UTC](https://discuss.elastic.co/t/how-to-group-space-separated-parts-of-a-message-into-one-field-in-grok/77181/4 "2017-04-04T06:25:10Z")

</div>

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