# Failed to parse date

**URL:** https://discuss.elastic.co/t/failed-to-parse-date/206081
**Category:** Logstash
**Created:** [October 31, 2019, 4:37pm UTC](https://discuss.elastic.co/t/failed-to-parse-date/206081 "2019-10-31T16:37:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![imaad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imaad/32/48628_2.png) [@imaad](https://discuss.elastic.co/u/imaad)
#### Post date: [October 31, 2019, 4:37pm UTC](https://discuss.elastic.co/t/failed-to-parse-date/206081/1 "2019-10-31T16:37:39Z")

</div>

Hello guys,

I failed to parse this date 31/Oct/2019:10:52:48 +0100 using the date plugin :

> date {  
> match =\> ["date", "dd/MMM/YYYY:HH:mm:ss Z"]  
> }

This is the error I got 🙂

> Oct 31 12:08:42 centos7 logstash[22377]: [2019-10-31T12:08:42,568][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"proxy-squid-2019.10.31", :\_type=\>"\_doc", :routing=\>nil}, #LogStash::Event:0x73e3aad1], :response=\>{"index"=\>{"\_index"=\>"proxy-squid-2019.10.31", "\_type"=\>"\_doc", "\_id"=\>"voWTIm4BHhkVqHsrga0P", "status"=\>400, "error"=\>{"type"=\>"mapper\_parsing\_exception", "reason"=\>"failed to parse field [date] of type [date] in document with id 'voWTIm4BHhkVqHsrga0P'. Preview of field's value: '31/Oct/2019:10:52:48 +0100'", "caused\_by"=\>{"type"=\>"illegal\_argument\_exception", "reason"=\>"failed to parse date field [31/Oct/2019:10:52:48 +0100] with format [strict\_date\_optional\_time||epoch\_millis]", "caused\_by"=\>{"type"=\>"date\_time\_parse\_exception", "reason"=\>"Failed to parse with all enclosed parsers"}}}}}}

Thank you for your help

---

<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: [October 31, 2019, 5:18pm UTC](https://discuss.elastic.co/t/failed-to-parse-date/206081/2 "2019-10-31T17:18:13Z")

</div>

It's not the date filter that is failing, it is the mapping in elasticsearch. You would need a custom [time formatter](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html) in the index template. That's really an elasticsearch question, not a logstash question.

Edited to add: The default target of the date filter is @timestamp. Did you mean to parse the [date] field and overwrite it?

---

<div class="post-metadata">

### Author: ![imaad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imaad/32/48628_2.png) [@imaad](https://discuss.elastic.co/u/imaad)
#### Post date: [November 4, 2019, 10:32am UTC](https://discuss.elastic.co/t/failed-to-parse-date/206081/3 "2019-11-04T10:32:00Z")

</div>

Hello Badger,

Thank you for your help. Yes that's the point, I want to use the value of the field date : 31/Oct/2019:10:52:48 +0100 instead of the default target of the date filter @timestamp.

Thank you

---

<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: [November 4, 2019, 1:28pm UTC](https://discuss.elastic.co/t/failed-to-parse-date/206081/4 "2019-11-04T13:28:08Z")

</div>

OK, so use

```
date { match => ["date", "dd/MMM/YYYY:HH:mm:ss Z"] target => "date" }
```

---

<div class="post-metadata">

### Author: ![imaad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/imaad/32/48628_2.png) [@imaad](https://discuss.elastic.co/u/imaad)
#### Post date: [November 4, 2019, 2:58pm UTC](https://discuss.elastic.co/t/failed-to-parse-date/206081/5 "2019-11-04T14:58:48Z")

</div>

Thank you @Badger , it works.

---

<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: [December 2, 2019, 2:58pm UTC](https://discuss.elastic.co/t/failed-to-parse-date/206081/6 "2019-12-02T14:58:48Z")

</div>

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