# (Help needed) Same grok pattern, multiple matches

**URL:** <https://discuss.elastic.co/t/help-needed-same-grok-pattern-multiple-matches/113318>\
**Category:** Logstash\
**Created:** [December 27, 2017, 1:58pm UTC](https://discuss.elastic.co/t/help-needed-same-grok-pattern-multiple-matches/113318 "2017-12-27T13:58:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arthur\_Silva\_Sens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur_silva_sens/32/24913_2.png) [@Arthur\_Silva\_Sens](https://discuss.elastic.co/u/Arthur_Silva_Sens)\
**Post date:** [December 27, 2017, 1:58pm UTC](https://discuss.elastic.co/t/help-needed-same-grok-pattern-multiple-matches/113318/1 "2017-12-27T13:58:07Z")

</div>

Greetings,

I'm having a difficult time to classify some JBOSS logs when it sends me java exceptions.

Here is my logstash.config

```
filter {
  grok {
    match => { "message" => "\.(?<java_exception>(.)*Exception):(.|\r|\n)*" }
  }
}

```

And here a message example

```
Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open database "database" requested by the login. The login failed.

```

What I get in return is:

```
{
  "java_exception": "jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (com.microsoft.sqlserver.jdbc.SQLServerException"
}

```

What I would like to get in return is an array

```
{
  "java_exception": ["JBossResourceException", "SQLServerException"]
}

```

Does anyone knows if it is possible?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Arthur\_Silva\_Sens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arthur_silva_sens/32/24913_2.png) [@Arthur\_Silva\_Sens](https://discuss.elastic.co/u/Arthur_Silva_Sens)\
**Post date:** [December 27, 2017, 3:55pm UTC](https://discuss.elastic.co/t/help-needed-same-grok-pattern-multiple-matches/113318/2 "2017-12-27T15:55:57Z")

</div>

I've altered my grok filter to this:

`\.(?<java_exception>([A-z])*Exception):(.|\r|\n)*`

So now I get a better result:

```
{
  "java_exception": "JBossResourceException"
}

```

But still, I needed both matches:

```
{
  "java_exception": ["JBossResourceException", "SQLServerException"]
}

```

Anything that could help?

---

<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:** [January 24, 2018, 3:56pm UTC](https://discuss.elastic.co/t/help-needed-same-grok-pattern-multiple-matches/113318/3 "2018-01-24T15:56:19Z")

</div>

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