# Date filter not working - Logstash

**URL:** <https://discuss.elastic.co/t/date-filter-not-working-logstash/215880>\
**Category:** Logstash\
**Created:** [January 21, 2020, 1:00pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880 "2020-01-21T13:00:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shahid\_Mustafa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shahid_mustafa/32/46287_2.png) [@Shahid\_Mustafa](https://discuss.elastic.co/u/Shahid_Mustafa)\
**Post date:** [January 21, 2020, 1:00pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880/1 "2020-01-21T13:00:07Z")

</div>

I am trying to use following date filter to convert string to date but it doesn't seem to be working.

Sample input data(string) - Jan 20 09:20:35 GMT 2020

I am first using a mutate gsub to remove GMT which renders following string output-  
Jan 20 09:20:35 2020

My gsub mutate filter looks like this -

mutate { gsub =\> ["TimeStamp", "GMT", ""] }

Now, I am using a date filter to convert gsub output to date format but it doesn't seem to be working-

date {  
match =\> ["TimeStamp", "EEE MMM dd HH:mm:ss yyyy"]  
target =\> "TimeStamp"  
locale =\> "en"  
}

I have also tried following with no success-

date {  
match =\> ["TimeStamp", "EEE\sMMM\sdd\sHH:mm:ss\s+yyyy"]  
target =\> "TimeStamp"  
timezone =\> "Etc/GMT"  
locale =\> "en"  
}

---

<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:** [January 21, 2020, 1:10pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880/2 "2020-01-21T13:10:07Z")

</div>

If you do not have a space in the mutate that removes the GMT then you will have two spaces in the field and will need two spaces in the date filter.

---

<div class="post-metadata">

**Author:** ![Shahid\_Mustafa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shahid_mustafa/32/46287_2.png) [@Shahid\_Mustafa](https://discuss.elastic.co/u/Shahid_Mustafa)\
**Post date:** [January 21, 2020, 1:20pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880/3 "2020-01-21T13:20:20Z")

</div>

Thanks for your reply. I actually have 2 spaces in filter. The space was removed while pasting here.

---

<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:** [January 21, 2020, 1:22pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880/4 "2020-01-21T13:22:16Z")

</div>

Your example data does not contain the day of the week, but your pattern has EEE.

---

<div class="post-metadata">

**Author:** ![Shahid\_Mustafa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shahid_mustafa/32/46287_2.png) [@Shahid\_Mustafa](https://discuss.elastic.co/u/Shahid_Mustafa)\
**Post date:** [January 21, 2020, 6:37pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880/5 "2020-01-21T18:37:13Z")

</div>

Sorry there was a typo in in the original date string I posted. It indeed has a weekday. It actually looks like Mon Jan 20 09:20:35 GMT 2020

---

<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:** [January 21, 2020, 8:15pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880/6 "2020-01-21T20:15:52Z")

</div>

What value do you end up with in the [TimeStamp] field?

---

<div class="post-metadata">

**Author:** ![Shahid\_Mustafa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shahid_mustafa/32/46287_2.png) [@Shahid\_Mustafa](https://discuss.elastic.co/u/Shahid_Mustafa)\
**Post date:** [January 21, 2020, 8:33pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880/7 "2020-01-21T20:33:55Z")

</div>

Jan 20 09:20:35 2020

Basically the same value that comes as the output from the gsub filter. (2 spaces between :35 and 2020)

Note: The extra space is getting removed when I try to post my comment here.

---

<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 18, 2020, 8:34pm UTC](https://discuss.elastic.co/t/date-filter-not-working-logstash/215880/8 "2020-02-18T20:34:06Z")

</div>

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