# Match error grok filter

**URL:** <https://discuss.elastic.co/t/match-error-grok-filter/283851>\
**Category:** Logstash\
**Created:** [September 10, 2021, 8:55am UTC](https://discuss.elastic.co/t/match-error-grok-filter/283851 "2021-09-10T08:55:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mar-ro](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mar-ro](https://discuss.elastic.co/u/mar-ro)\
**Post date:** [September 10, 2021, 8:55am UTC](https://discuss.elastic.co/t/match-error-grok-filter/283851/1 "2021-09-10T08:55:57Z")

</div>

Good morning!

I'm trying to set up a grok filter to a pipeline which receives the following text:

`09/10/2021, 8:30:00 AM [Message]`

therefore the date format is: Month/Day/Year, Hour:Minutes:Seconds

The grok filter looks like this:

```auto
   grok {
    match => { "message" => "(?<custom_date>%{MONTHNUM}/%{MONTHDAY}/%{YEAR}, %{HOUR}:%{MINUTE}:%{SECOND})"}
    tag_on_failure => ["no_date_found"]
   }

```

but I can't get logstash to recognise that date correctly. What I have to change in the match expresion to fix this? Thank you !!

---

<div class="post-metadata">

**Author:** ![Cad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cad/32/86661_2.png) [@Cad](https://discuss.elastic.co/u/Cad)\
**Post date:** [September 10, 2021, 10:04pm UTC](https://discuss.elastic.co/t/match-error-grok-filter/283851/2 "2021-09-10T22:04:39Z")

</div>

Hi,

Can you add `stdout { codec => rubydebug }` to the output part and show us the result when you have a `no_date_found` please.  
Because currently the grok pattern work.

Cad.

---

<div class="post-metadata">

**Author:** ![chandu5565](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@chandu5565](https://discuss.elastic.co/u/chandu5565)\
**Post date:** [September 11, 2021, 3:18pm UTC](https://discuss.elastic.co/t/match-error-grok-filter/283851/3 "2021-09-11T15:18:44Z")

</div>

Hi Miguel,

you missed to give the expression for AM , message after the time because of which grok failed to match the message.

use the below grok pattern it should work.

```auto
   grok {
    match => { "message" => "(?<custom_date>%{MONTHNUM}/%{MONTHDAY}/%{YEAR}, %{HOUR}:%{MINUTE}:%{SECOND} %{WORD})%{GREEDYDATA:actual_message}"}
    tag_on_failure => ["no_date_found"]
   }

```

---

<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 11, 2021, 3:24pm UTC](https://discuss.elastic.co/t/match-error-grok-filter/283851/4 "2021-09-11T15:24:43Z")

</div>

> [@chandu5565](#):
>
> you missed to give the expression for AM

grok does not need to consume the entire field it is matching against. The grok pattern that Miguel gave matches "09/10/2021, 8:30:00", and when tested in logstash it matches.

Consuming the AM affects the value of the timestamp (at least when it is PM) but does not prevent the grok pattern matching.

---

<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:** [October 9, 2021, 3:25pm UTC](https://discuss.elastic.co/t/match-error-grok-filter/283851/5 "2021-10-09T15:25:00Z")

</div>

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