# Filter a string date format on logstash

**URL:** https://discuss.elastic.co/t/filter-a-string-date-format-on-logstash/84016
**Category:** Logstash
**Created:** [April 28, 2017, 1:40pm UTC](https://discuss.elastic.co/t/filter-a-string-date-format-on-logstash/84016 "2017-04-28T13:40:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Djelouah\_Laala](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Djelouah\_Laala](https://discuss.elastic.co/u/Djelouah_Laala)
#### Post date: [April 28, 2017, 1:40pm UTC](https://discuss.elastic.co/t/filter-a-string-date-format-on-logstash/84016/1 "2017-04-28T13:40:58Z")

</div>

Hi guys,

I get data from an sql server database and i have a date on a string format like this :  
_"2017-04-25 00:00:00 +0200"_ and I want to use grok filter to transform this to a similar format to @timestamp  
I have this code `grok { match => ["message","(?<log_date>%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{HOUR}:%{MINUTE}:%{SECOND},[0-9]{3}) %{GREEDYDATA:jsonfield}"] }`

In Kibana i got this error message :  
**Expected numeric type on field [txechecczhier\_date], but got [string]**

So i suppose that the problem come from my filter, any idea guys to help to solve this?

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: [April 28, 2017, 1:44pm UTC](https://discuss.elastic.co/t/filter-a-string-date-format-on-logstash/84016/2 "2017-04-28T13:44:17Z")

</div>

Extract the whole timestamp string to a separate field and use the date filter to parse it into `@timestamp`.

---

<div class="post-metadata">

### Author: ![Djelouah\_Laala](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Djelouah\_Laala](https://discuss.elastic.co/u/Djelouah_Laala)
#### Post date: [April 28, 2017, 1:50pm UTC](https://discuss.elastic.co/t/filter-a-string-date-format-on-logstash/84016/3 "2017-04-28T13:50:17Z")

</div>

Thank you for replying me as quickly. When i delete the filter i have this result in a file :  
`{"txechecczhier_date":"2017-04-25 00:00:00 +0200","txechecczhier_tx":2.08,"@version":"1","@timestamp":"2017-04-28T12:51:01.476Z"}`  
I want to display my txechecczhier\_date in kibana, the date is different from the timestamp. With date filter we can transform a string to a timestamp?

---

<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: [April 28, 2017, 1:56pm UTC](https://discuss.elastic.co/t/filter-a-string-date-format-on-logstash/84016/4 "2017-04-28T13:56:16Z")

</div>

> With date filter we can transform a string to a timestamp?

Yes, that's exactly what that filter does.

---

<div class="post-metadata">

### Author: ![Djelouah\_Laala](https://avatars.discourse-cdn.com/v4/letter/d/f9ae1b/32.png) [@Djelouah\_Laala](https://discuss.elastic.co/u/Djelouah_Laala)
#### Post date: [April 28, 2017, 1:57pm UTC](https://discuss.elastic.co/t/filter-a-string-date-format-on-logstash/84016/5 "2017-04-28T13:57:16Z")

</div>

Okay ! thank you, i will look in this way

---

<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 26, 2017, 1:58pm UTC](https://discuss.elastic.co/t/filter-a-string-date-format-on-logstash/84016/6 "2017-05-26T13:58:33Z")

</div>

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