# Grok pattern for snort alerts

**URL:** <https://discuss.elastic.co/t/grok-pattern-for-snort-alerts/306625>\
**Category:** Logstash\
**Created:** [June 8, 2022, 5:28am UTC](https://discuss.elastic.co/t/grok-pattern-for-snort-alerts/306625 "2022-06-08T05:28:19Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [June 8, 2022, 5:31pm UTC](https://discuss.elastic.co/t/grok-pattern-for-snort-alerts/306625/4 "2022-06-08T17:31:09Z")

</div>

You can make a field (and related whitespace) option by surrounding them with `()?`, which means zero-or-more-of.

```
grok { match => { "message" => "%{MONTHNUM:month}\/%{MONTHDAY:day}-%{HOUR:hour}:%{MINUTE:minute}:%{SECOND:second}\s+\[\*\*\] \[%{INT:ids_gid}:%{INT:ids_sid}:%{INT:ids_rev}\]\s+%{DATA:ids_proto}\s+\[\*\*\] (\[.*?: %{DATA:Classification}\] )?\[.*?: %{INT:Priority}\] \{%{DATA:data}} %{IP:dst_ip} .*?> %{IP:dest_port}" } }

```

If there are more variants then you might want to take an alternate approach. Perhaps something like [this](https://discuss.elastic.co/t/metatrader-how-parse-such-logs/248406/2).

---

_[View the full topic](https://discuss.elastic.co/t/grok-pattern-for-snort-alerts/306625)._
