# Grok Pattern for date and time format "03-MAR-21 00:40:21"

**URL:** <https://discuss.elastic.co/t/grok-pattern-for-date-and-time-format-03-mar-21-0021/271014>\
**Category:** Logstash\
**Created:** [April 22, 2021, 8:33pm UTC](https://discuss.elastic.co/t/grok-pattern-for-date-and-time-format-03-mar-21-0021/271014 "2021-04-22T20:33:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wilks](https://avatars.discourse-cdn.com/v4/letter/w/f475e1/32.png) [@Wilks](https://discuss.elastic.co/u/Wilks)\
**Post date:** [April 22, 2021, 8:33pm UTC](https://discuss.elastic.co/t/grok-pattern-for-date-and-time-format-03-mar-21-0021/271014/1 "2021-04-22T20:33:55Z")

</div>

This is likely a simple one but what's the grok pattern for this? I have gone through all the ones I could find but I cant get a match for the format 03-MAR-21 00:40:2

Currently I am using a string but need to change it from a string to a time as its causing reporting issues

```auto
grok {
         match => { "message" => [ "%{GREEDYDATA:timestamp}
          }

date {
        match => ["timestamp", "dd-MMM-yy HH:mm:ss"]
        target => "@timestamp"
      }

```

---

<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:** [April 22, 2021, 10:17pm UTC](https://discuss.elastic.co/t/grok-pattern-for-date-and-time-format-03-mar-21-0021/271014/2 "2021-04-22T22:17:42Z")

</div>

That appears to match the core TIMESTAMP\_ISO8601 pattern, so you could use

```
grok { match => { "message" => "%{TIMESTAMP_ISO8601 :timestamp}" } }

```

I normally think of ISO8601 dates as having four digit years, but the pattern works with two as well.

---

<div class="post-metadata">

**Author:** ![Wilks](https://avatars.discourse-cdn.com/v4/letter/w/f475e1/32.png) [@Wilks](https://discuss.elastic.co/u/Wilks)\
**Post date:** [April 23, 2021, 12:38am UTC](https://discuss.elastic.co/t/grok-pattern-for-date-and-time-format-03-mar-21-0021/271014/3 "2021-04-23T00:38:42Z")

</div>

Thanks for the response.  
I tried that but I get "\_grokparsefailure". If I try "%{TIMESTAMP\_ISO8601:timestamp}" on the grok debugger tool it fails as well.

![grokfail](https://us1.discourse-cdn.com/elastic/original/3X/c/4/c40f175d0d3af7139d97439c8050fbaf9b1e8bd5.png)

![grokdebbuger](https://us1.discourse-cdn.com/elastic/original/3X/7/2/7266c7c7fa2799db3586d142d6e635d48c55e500.png)

---

<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:** [April 23, 2021, 1:12am UTC](https://discuss.elastic.co/t/grok-pattern-for-date-and-time-format-03-mar-21-0021/271014/4 "2021-04-23T01:12:04Z")

</div>

Sorry, if the month abbreviation is all upper case you will need a custom pattern

```
    grok {
        pattern_definitions => {
            "CUSTOMMONTH" => "(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)"
            "CUSTOMTIMESTAMP" => "%{YEAR}-%{CUSTOMMONTH}-%{MONTHDAY} %{TIME}"
        }
        match => { "message" => "%{CUSTOMTIMESTAMP:timestamp}" }
    }
```

---

<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:** [May 21, 2021, 1:12am UTC](https://discuss.elastic.co/t/grok-pattern-for-date-and-time-format-03-mar-21-0021/271014/5 "2021-05-21T01:12:49Z")

</div>

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