# Not able to parse date in format "YYYY-mm-dd:HH:mm:ss" using grok pattern

**URL:** <https://discuss.elastic.co/t/not-able-to-parse-date-in-format-yyyy-mm-dd-hh-mm-ss-using-grok-pattern/74656>\
**Category:** Logstash\
**Created:** [February 10, 2017, 1:40pm UTC](https://discuss.elastic.co/t/not-able-to-parse-date-in-format-yyyy-mm-dd-hh-mm-ss-using-grok-pattern/74656 "2017-02-10T13:40:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anisen](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@anisen](https://discuss.elastic.co/u/anisen)\
**Post date:** [February 10, 2017, 1:40pm UTC](https://discuss.elastic.co/t/not-able-to-parse-date-in-format-yyyy-mm-dd-hh-mm-ss-using-grok-pattern/74656/1 "2017-02-10T13:40:56Z")

</div>

My Log file looks like this:

**2015-06-12:00:08:55** 195.160.1.191 POST /abc/xyz - 80 - 192.160.1.129 Mozilla/4.0+(compatible;+MSIE+4.01;+Windows+NT;+MS+Search+6.0+Robot) - 401 0 0 37  
2015-06-12:00:08:54 195.160.1.191 POST /abc/xyz - 80 - 192.168.1.159 Mozilla/4.0+(compatible;+MSIE+4.01;+Windows+NT;+MS+Search+6.0+Robot) - 401 1 2148075254 5

I am using the below grok:

grok {  
match =\> {  
"message" =\> '%{ **HTTPDATE** :timestamp} %{IPORHOST:clientip} %{NOTSPACE:method} %{NOTSPACE:uri} %{NOTSPACE:csuriquery} %{NOTSPACE:port} %{NOTSPACE:username} %{NOTSPACE:serverip} %{DATA:agent} %{NOTSPACE:referrer} %{NOTSPACE:status} %{NOTSPACE:sub\_status} %{NOTSPACE:winstatus} %{NOTSPACE:responsetime}'  
}  
}

date {  
match =\> ["timestamp", " **YYYY-mm-dd:HH:mm:ss**"]  
locale =\> en  
}

But, it is not parsing the date properly with HTTPDATE. What grok pattern should I use?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 12, 2017, 6:31pm UTC](https://discuss.elastic.co/t/not-able-to-parse-date-in-format-yyyy-mm-dd-hh-mm-ss-using-grok-pattern/74656/2 "2017-02-12T18:31:44Z")

</div>

Yeah, HTTPDATE won't match your timestamp format. Try this instead of `%{HTTPDATE:timestamp}`:

```
(?<timestamp>%{YEAR}-%{MONTHNUM}-%{MONTHDAY}:%{TIME})

```

Secondly, the pattern in your date filter can't possibly work since you have two occurrences of "mm".

---

<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:** [March 12, 2017, 6:31pm UTC](https://discuss.elastic.co/t/not-able-to-parse-date-in-format-yyyy-mm-dd-hh-mm-ss-using-grok-pattern/74656/3 "2017-03-12T18:31:48Z")

</div>

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