# Date field in logstash

**URL:** <https://discuss.elastic.co/t/date-field-in-logstash/141934>\
**Category:** Logstash\
**Created:** [July 27, 2018, 11:41am UTC](https://discuss.elastic.co/t/date-field-in-logstash/141934 "2018-07-27T11:41:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![waitangi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waitangi/32/110887_2.png) [@waitangi](https://discuss.elastic.co/u/waitangi)\
**Post date:** [July 27, 2018, 11:41am UTC](https://discuss.elastic.co/t/date-field-in-logstash/141934/1 "2018-07-27T11:41:03Z")

</div>

Hi

I use logstash to put my IIS log files to elseicsearch. I use my own grok filter:  
"message", "%{TIMESTAMP\_ISO8601:request\_timestamp} %{IP:server\_ip} %{WORD:request\_method} %{URIPATH:request\_uri} %{NOTSPACE:request\_query} %{NUMBER:port} %{NOTSPACE:username} %{IP:client\_ip} %{NOTSPACE:request\_agent} %{NOTSPACE:request\_referer} %{INT:response\_status} %{INT:response\_substatus} %{INT:response\_winstatus} %{INT:response\_timetaken}"

Then I use DSL query to elasticsearch to get the logs where request\_timestamp field is in specified date range, and there are logs from outside the range.  
However if I take range using @timestamp column the results seems to be fine - so In my opinion the problem is with field type.  
I have even defined an index template where my field definitione is:  
"request\_timestamp" : {  
"type" : "date",  
"format" : "yyyy-MM-dd HH:mm:ss"  
}  
but it still does not work (default logstash definitione was text).  
How to solve it? Or even better how to use date from my logs as @timestamp column, which in my specific case is completelly useless.

---

<div class="post-metadata">

**Author:** ![davemoore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davemoore/32/134233_2.png) [@davemoore](https://discuss.elastic.co/u/davemoore)\
**Post date:** [July 27, 2018, 12:48pm UTC](https://discuss.elastic.co/t/date-field-in-logstash/141934/2 "2018-07-27T12:48:31Z")

</div>

@waitangi

Have you verified if the timezone of your query matches the timezone of your `request_timestamp` values?

---

<div class="post-metadata">

**Author:** ![waitangi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waitangi/32/110887_2.png) [@waitangi](https://discuss.elastic.co/u/waitangi)\
**Post date:** [July 30, 2018, 8:10am UTC](https://discuss.elastic.co/t/date-field-in-logstash/141934/3 "2018-07-30T08:10:46Z")

</div>

Got it. I added timezone =\> "UTC" to date definition in configuration file, Then I added remove\_field =\> ["request\_timestamp"] and now I have in @timestamp parsed date from the log file and no request\_timestamp column. It suits me fine.  
Thanks davemoore.

---

<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:** [August 27, 2018, 8:10am UTC](https://discuss.elastic.co/t/date-field-in-logstash/141934/4 "2018-08-27T08:10:52Z")

</div>

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