# Multiple Grok patterns help

**URL:** <https://discuss.elastic.co/t/multiple-grok-patterns-help/282965>\
**Category:** Logstash\
**Created:** [August 31, 2021, 10:15pm UTC](https://discuss.elastic.co/t/multiple-grok-patterns-help/282965 "2021-08-31T22:15:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zorkmid](https://avatars.discourse-cdn.com/v4/letter/z/e68b1a/32.png) [@Zorkmid](https://discuss.elastic.co/u/Zorkmid)\
**Post date:** [August 31, 2021, 10:15pm UTC](https://discuss.elastic.co/t/multiple-grok-patterns-help/282965/1 "2021-08-31T22:15:06Z")

</div>

Hi All,  
I'm doing something wrong with the following. The goal is parse 5 basic events from a PulseSecure VPN syslog feed. Is the following the correct??

```auto
filter {
    if "PulseSecure" in [message] {

         grok {
            match => {

            "message" => [
                        “%{SYSLOGBASE} %{TIMESTAMP_ISO8601:timestamp} - %{WORD:IVE} - \[%{IP:ClientIP}\] (?<UserID>[^(]*)(?<VpnProfile>(.*?))\[(?<Realm>(.*?))\] - %{GREEDYDATA:message}”,
                        “%{SYSLOGBASE} %{TIMESTAMP_ISO8601:timestamp} - %{WORD:IVE} - \[%{IP:ClientIP}\] (?<UserID>[^(]*)(?<VpnProfile>(.*?))\[(?<Realm>(.*?))\] - %{GREEDYDATA:message} (?<AssignedIP>((?:[0-9]{1,3}\.){3}[0-9]{1,3})\s)”,
                        “%{SYSLOGBASE} %{TIMESTAMP_ISO8601:timestamp} - %{WORD:IVE} - \[%{IP:ClientIP}\] (?<UserID>[^(]*)(?<VpnProfile>(.*?))\[(?<Realm>(.*?))\] - (?<ERROR_MSG>(.*?)\)\.) %{GREEDYDATA:message}\#”,
                        “%{SYSLOGBASE} %{TIMESTAMP_ISO8601:timestamp} - %{WORD:IVE} - \[%{IP:ClientIP}\] (?<UserID>[^(]*)(?<VpnProfile>(.*?))\[(?<Realm>(.*?))\] - (?<SSL_Failure>SSL (.*?))\. %{GREEDYDATA:message}\#”,
                        “%{SYSLOGBASE} %{TIMESTAMP_ISO8601:timestamp} - %{WORD:IVE} - \[%{IP:ClientIP}\] (?<UserID>[^(]*)(?<VpnProfile>(.*?))\[(?<Realm>(.*?))\] - CRL(?<CRL>(.*?))\s\'CN\=(?<UserName>(.*?))\,\sOU\=(?<OrgName>(.*?))\,\s%{GREEDYDATA:message}”
                        ]
                 }
          }
    }
}

```

Regards  
TimW

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 31, 2021, 11:54pm UTC](https://discuss.elastic.co/t/multiple-grok-patterns-help/282965/2 "2021-08-31T23:54:49Z")

</div>

> [@Zorkmid](#):
>
> Is the following the correct?

No. You need to match the most specific pattern first, then get gradually less specific. In your case the first pattern will match every time.

I suggest you also read through [this](https://discuss.elastic.co/t/grok-increase-cpu-usage-to-700/256633/2) post, since you can probably greatly speed up that configuration.

---

<div class="post-metadata">

**Author:** ![Zorkmid](https://avatars.discourse-cdn.com/v4/letter/z/e68b1a/32.png) [@Zorkmid](https://discuss.elastic.co/u/Zorkmid)\
**Post date:** [September 1, 2021, 4:05am UTC](https://discuss.elastic.co/t/multiple-grok-patterns-help/282965/3 "2021-09-01T04:05:16Z")

</div>

Thanks Badger and understood on the ordering of the patterns.

2nd task is to find out why the above even if reduced to a single pattern causes logstash to error with a config issue. :--)

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 1, 2021, 5:05am UTC](https://discuss.elastic.co/t/multiple-grok-patterns-help/282965/4 "2021-09-01T05:05:32Z")

</div>

> [@Zorkmid](#):
>
> `“`

Perhaps the use of curly quotes. Use double quotes -- "

---

<div class="post-metadata">

**Author:** ![Zorkmid](https://avatars.discourse-cdn.com/v4/letter/z/e68b1a/32.png) [@Zorkmid](https://discuss.elastic.co/u/Zorkmid)\
**Post date:** [September 1, 2021, 3:17pm UTC](https://discuss.elastic.co/t/multiple-grok-patterns-help/282965/5 "2021-09-01T15:17:19Z")

</div>

oh dear - killed by cut and paste and overly helpful app!!!  
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:** [September 29, 2021, 3:17pm UTC](https://discuss.elastic.co/t/multiple-grok-patterns-help/282965/6 "2021-09-29T15:17:57Z")

</div>

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