# Cannot parse logs with date filter

**URL:** https://discuss.elastic.co/t/cannot-parse-logs-with-date-filter/100891
**Category:** Logstash
**Created:** [September 18, 2017, 2:50pm UTC](https://discuss.elastic.co/t/cannot-parse-logs-with-date-filter/100891 "2017-09-18T14:50:49Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![omer](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@omer](https://discuss.elastic.co/u/omer)
#### Post date: [September 18, 2017, 2:50pm UTC](https://discuss.elastic.co/t/cannot-parse-logs-with-date-filter/100891/1 "2017-09-18T14:50:49Z")

</div>

Hi;

i am trying to parse my logs to fields but as you guess i failed 😃

Here is a sample of my logs.

[INFO] 23.08.2017 20:28:32.941 in [pool-2-thread-20] |com.defne.rbt.eventapi.client.kvp.EventJob:eventCall:239| - Response returned for Call event: Success

Firstly, i tried to use just date filter such that

filter{  
date {  
match =\> ["message", "dd.MM.yyyy HH:mm:ss.SSS"]  
}

}

However it could not find the date in the message. Then i tried to parse it with grok filter but i failed there too. I could not create fields to put it in the date filter. Indeed,i probably made mistakes in grok. How can i parse it. How can i get the correct timestamp. Need help!... 😃

Thank you.

---

<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: [September 19, 2017, 7:38pm UTC](https://discuss.elastic.co/t/cannot-parse-logs-with-date-filter/100891/2 "2017-09-19T19:38:07Z")

</div>

First use a grok filter to extract _only_ the timestamp into a separate field, then feed that field to the date filter.

The grok constructor web site can help you create a grok expression for your log.

---

<div class="post-metadata">

### Author: ![omer](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@omer](https://discuss.elastic.co/u/omer)
#### Post date: [September 20, 2017, 8:27am UTC](https://discuss.elastic.co/t/cannot-parse-logs-with-date-filter/100891/3 "2017-09-20T08:27:56Z")

</div>

I used grok constructor and get seperated fields. You mentioned that i should only get timestamp but cannot do that. Instead, i get random fields. Grok constructor says it is matched. But when i use it at logstash, i get \_grokparsefailure.

Here are both grok and date filters.

filter{  
grok{  
match =\> {"message" =\> "[%{LOGLEVEL:level}%{SPACE}] (?%{MONTHDAY}.%{MONTHNUM}.%{YEAR} %{TIME}) %{WORD:in} [%{WORD:thread}] |%{DATA:host}| - %{DATA:message}"}  
}  
date{  
match =\> ["date", "dd.MM.yyyy HH:mm:ss.SSS"]  
}  
}

and grok constructor results:

MATCHED  
in in  
host com.defne.rbt.eventapi.client.kvp.EventJob:eventCall:239  
thread pool-2-thread-20  
date 23.08.2017·20:28:32.941  
message   
level INFO  
after match: Response returned for Call event: Success

So, didnt work. Where do i make mistakes?

Thanks for reply...

---

<div class="post-metadata">

### Author: ![omer](https://avatars.discourse-cdn.com/v4/letter/o/258eb7/32.png) [@omer](https://discuss.elastic.co/u/omer)
#### Post date: [September 20, 2017, 9:09am UTC](https://discuss.elastic.co/t/cannot-parse-logs-with-date-filter/100891/4 "2017-09-20T09:09:17Z")

</div>

Oh my bad... I changed {WORD:thread} to {DATA:thread} and {DATA:message} to {GREEDYDATA:message} and boooom... it worked! 🤣🤣

Now, i just wonder how can i get _only_ timestamp in the log files?

---

<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 18, 2017, 9:09am UTC](https://discuss.elastic.co/t/cannot-parse-logs-with-date-filter/100891/5 "2017-10-18T09:09:24Z")

</div>

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