# \_dateparsefailure While parsing string

**URL:** <https://discuss.elastic.co/t/-dateparsefailure-while-parsing-string/72616>\
**Category:** Logstash\
**Created:** [January 24, 2017, 10:49am UTC](https://discuss.elastic.co/t/-dateparsefailure-while-parsing-string/72616 "2017-01-24T10:49:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tugrulcan](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@tugrulcan](https://discuss.elastic.co/u/tugrulcan)\
**Post date:** [January 24, 2017, 10:49am UTC](https://discuss.elastic.co/t/-dateparsefailure-while-parsing-string/72616/1 "2017-01-24T10:49:16Z")

</div>

Hi,  
Logstash parses logdate field as string. I tried to convert it to datetime (24h format) using date filter, but I get the "\_dateparsefailure" error when I try to parse a log line. Could you please help me to parse datetime correctly? What am I missing?

Sample log line: `11/28/2016 11:08:17 AM Mr INFO Creating application []`  
And here is logstash grok filter that I'm using :

filter {  
grok {  
match =\> {"message" =\> "(?%{DATE} %{TIME} (?:AM|PM)) %{DATA:class} %{LOGLEVEL:log-level} %{GREEDYDATA:event\_desc} [%{GREEDYDATA:traceback}]"}  
}

```
date {
  match => ["logdate", "dd/MM/yyyy KK:mm:ss aa"]
  target => "@timestamp"
  add_field => { "debug" => "timestampMatched"}
}

```

}

And the rubydebug output is here:  
{  
"offset" =\> 182,  
"input\_type" =\> "log",  
"source" =\> "logs/2016\_11\_28\_11\_08\_17\_log.txt",  
"message" =\> "11/28/2016 11:08:17 AM Mr INFO Creating application []",  
"type" =\> "log",  
"tags" =\> [  
[0] "beats\_input\_codec\_plain\_applied",  
[1] "\_dateparsefailure"  
],  
"event\_desc" =\> "Creating application",  
"@timestamp" =\> 2017-01-24T10:47:12.657Z,  
"log-level" =\> "INFO",  
"logdate" =\> "11/28/2016 11:08:17 AM",  
"@version" =\> "1",  
"beat" =\> {  
"hostname" =\> "ed15f9e21523",  
"name" =\> "ed15f9e21523"  
},  
"host" =\> "ed15f9e21523",  
"class" =\> "Mr"  
}

---

<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:** [January 24, 2017, 8:14pm UTC](https://discuss.elastic.co/t/-dateparsefailure-while-parsing-string/72616/2 "2017-01-24T20:14:52Z")

</div>

With a date like 11/28/2016 your dd/MM/yyyy pattern is clearly wrong (flip the day and the month). Apart from that it looks okay.

---

<div class="post-metadata">

**Author:** ![tugrulcan](https://avatars.discourse-cdn.com/v4/letter/t/8e8cbc/32.png) [@tugrulcan](https://discuss.elastic.co/u/tugrulcan)\
**Post date:** [January 25, 2017, 8:01am UTC](https://discuss.elastic.co/t/-dateparsefailure-while-parsing-string/72616/3 "2017-01-25T08:01:37Z")

</div>

It's working, thanks!

---

<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:** [February 22, 2017, 8:02am UTC](https://discuss.elastic.co/t/-dateparsefailure-while-parsing-string/72616/4 "2017-02-22T08:02:02Z")

</div>

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