# Logstash is not taking logdate as @timestamp field although it is taking the received time as @timestamp field

**URL:** <https://discuss.elastic.co/t/logstash-is-not-taking-logdate-as-timestamp-field-although-it-is-taking-the-received-time-as-timestamp-field/28370>\
**Category:** Logstash\
**Created:** [August 31, 2015, 5:45pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-logdate-as-timestamp-field-although-it-is-taking-the-received-time-as-timestamp-field/28370 "2015-08-31T17:45:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yashpal\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yashpal_singh/32/43209_2.png) [@Yashpal\_Singh](https://discuss.elastic.co/u/Yashpal_Singh)\
**Post date:** [August 31, 2015, 5:45pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-logdate-as-timestamp-field-although-it-is-taking-the-received-time-as-timestamp-field/28370/1 "2015-08-31T17:45:19Z")

</div>

Hi All,  
I am also facing the same problem Logstash is not considering my log date rather making the date at which I am forwarding the logs as @timeStamp field.  
I am using

date {  
match =\> ["logdate", "YYYY-MM-dd HH:mm:ss,SSS Z"]

```
}
```

---

<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:** [August 31, 2015, 6:02pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-logdate-as-timestamp-field-although-it-is-taking-the-received-time-as-timestamp-field/28370/2 "2015-08-31T18:02:06Z")

</div>

Okay, but what's in your `logdate` field? And what's in the Logstash log? If a date pattern won't match it'll usually point you to where the error is.

---

<div class="post-metadata">

**Author:** ![Yashpal\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yashpal_singh/32/43209_2.png) [@Yashpal\_Singh](https://discuss.elastic.co/u/Yashpal_Singh)\
**Post date:** [September 1, 2015, 10:23am UTC](https://discuss.elastic.co/t/logstash-is-not-taking-logdate-as-timestamp-field-although-it-is-taking-the-received-time-as-timestamp-field/28370/3 "2015-09-01T10:23:33Z")

</div>

@magnusbaeck I have logs which have the below pattern

LOGS  
 2015-02-04 14:28:30,375 +0000

Logstash Config

grok {  
match =\> ["message", "%{Name:name} %{WORD:role} %{xyz\_DATE:logdate}"]  
patterns\_dir =\> "/etc/logstash/patterns"  
}  
date {  
match =\> ["logdate", "YYYY-MM-dd HH:mm:ss,SSS Z"]  
target =\> "@timestamp"  
}

Pattern to match date field : (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} [+-]\d{4})

I have checked the logstash log , I haven't getting any parsing error , Hence I assumed the date is parse correctly . Moreover I have checked in kibana my "logDate" field is correctly populated.

---

<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 1, 2015, 5:54pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-logdate-as-timestamp-field-although-it-is-taking-the-received-time-as-timestamp-field/28370/4 "2015-09-01T17:54:16Z")

</div>

I can't reproduce with Logstash 1.5.3:

```
$ cat test.config
input { stdin { } }
output { stdout { codec => rubydebug } }
filter {
  date {
    match => ["message", "YYYY-MM-dd HH:mm:ss,SSS Z"]
  }
}
$ echo '2015-02-04 14:28:30,375 +0000' | /opt/logstash/bin/logstash -f test.config
Logstash startup completed
{
       "message" => "2015-02-04 14:28:30,375 +0000",
      "@version" => "1",
    "@timestamp" => "2015-02-04T14:28:30.375Z",
          "host" => "hallonet"
}
Logstash shutdown completed
```

---

<div class="post-metadata">

**Author:** ![Yashpal\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yashpal_singh/32/43209_2.png) [@Yashpal\_Singh](https://discuss.elastic.co/u/Yashpal_Singh)\
**Post date:** [September 8, 2015, 9:20am UTC](https://discuss.elastic.co/t/logstash-is-not-taking-logdate-as-timestamp-field-although-it-is-taking-the-received-time-as-timestamp-field/28370/5 "2015-09-08T09:20:40Z")

</div>

@magnusbaeck I have run the above example in my environment , I am getting the results as you are.

I have found the error , All the logs for which there is grokparse failure logstash is assigning the current date(Which is understandable)

Thanks for all your help.

---

<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:** [July 6, 2017, 5:29am UTC](https://discuss.elastic.co/t/logstash-is-not-taking-logdate-as-timestamp-field-although-it-is-taking-the-received-time-as-timestamp-field/28370/6 "2017-07-06T05:29:45Z")

</div>


