# How to overwrite Log time values with @timestamp

**URL:** <https://discuss.elastic.co/t/how-to-overwrite-log-time-values-with-timestamp/66689>\
**Category:** Logstash\
**Created:** [November 21, 2016, 8:55am UTC](https://discuss.elastic.co/t/how-to-overwrite-log-time-values-with-timestamp/66689 "2016-11-21T08:55:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivin\_Pai](https://avatars.discourse-cdn.com/v4/letter/v/48db29/32.png) [@Vivin\_Pai](https://discuss.elastic.co/u/Vivin_Pai)\
**Post date:** [November 21, 2016, 8:55am UTC](https://discuss.elastic.co/t/how-to-overwrite-log-time-values-with-timestamp/66689/1 "2016-11-21T08:55:50Z")

</div>

I have created a conf file for Logstash.

input {  
file {  
path =\> "/advdata/tmp/Error\_Trace\_blrhpbl\_SC1\*.txt"  
start\_position =\> "beginning"  
}  
}

filter {  
date {  
match =\> ["logdate", "YYYY/MM/DD-HH:MM:SS"]  
}  
}

output {  
elasticsearch {  
hosts =\> ["localhost:9200"]  
user =\> "elastic"  
password =\> "changeme"  
}

stdout { codec =\> rubydebug }  
}

When i run the logstash, sample output

{  
"path" =\> "/advdata/tmp/Error\_Trace\_blrhpbl\_SC1\_19112016.txt",  
"@timestamp" =\> 2016-11-21T09:50:13.755Z,  
"@version" =\> "1",  
"host" =\> "blrvmds-03",  
"message" =\> "blrhpbl001-bl06:2016/11/19-07:25:11.741378-57989-60661-IMS\_G\_PCS\_CORE\_277- ERROR : (CCoGxServingState.cxx:989) CCoGxServingIdle#receiveSPRReadResp: ",  
"tags" =\> []  
}

Log file has the timestamp at 2016/11/19-07:25:11, whereas @timestamp shows 2016-11-21T09:50:13.755Z (current date on logstash machine). How do i replace the @time stamp with 2016/11/19-07:25:11 ?

---

<div class="post-metadata">

**Author:** ![Andrew\_Cholakian1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrew_cholakian1/32/3612_2.png) [@Andrew\_Cholakian1](https://discuss.elastic.co/u/Andrew_Cholakian1)\
**Post date:** [November 21, 2016, 4:59pm UTC](https://discuss.elastic.co/t/how-to-overwrite-log-time-values-with-timestamp/66689/2 "2016-11-21T16:59:31Z")

</div>

You will first need to parse out the `logdate` field, which it looks like is not done correctly. You'll need to use the `grok` filter to parse your message first.

---

<div class="post-metadata">

**Author:** ![Vivin\_Pai](https://avatars.discourse-cdn.com/v4/letter/v/48db29/32.png) [@Vivin\_Pai](https://discuss.elastic.co/u/Vivin_Pai)\
**Post date:** [November 28, 2016, 7:05am UTC](https://discuss.elastic.co/t/how-to-overwrite-log-time-values-with-timestamp/66689/3 "2016-11-28T07:05:01Z")

</div>

thanks it is working.

This is the filter used

filter {  
grok {  
match =\> { "message" =\> "%{DATE\_EU:date}-%{TIME:time}.[0-9]+" }  
}

mutate {  
gsub =\> ["date","/","-"]  
add\_field =\> { "timestamp" =\> "20%{date} %{time}" }  
}

date {  
match =\> ["timestamp", "YYYY-MM-dd HH:mm:ss"]  
timezone =\> "Asia/Calcutta"  
locale =\> "en"  
}  
}

---

<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:** [December 26, 2016, 7:05am UTC](https://discuss.elastic.co/t/how-to-overwrite-log-time-values-with-timestamp/66689/4 "2016-12-26T07:05:01Z")

</div>

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