# Get the correct timestamp from the log file

**URL:** <https://discuss.elastic.co/t/get-the-correct-timestamp-from-the-log-file/32633>\
**Category:** Logstash\
**Created:** [October 21, 2015, 4:34am UTC](https://discuss.elastic.co/t/get-the-correct-timestamp-from-the-log-file/32633 "2015-10-21T04:34:01Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Surbhi\_Agarwal](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Surbhi\_Agarwal](https://discuss.elastic.co/u/Surbhi_Agarwal)\
**Post date:** [October 21, 2015, 7:06am UTC](https://discuss.elastic.co/t/get-the-correct-timestamp-from-the-log-file/32633/5 "2015-10-21T07:06:37Z")

</div>

This is my log file:

21/Oct/2015:12:28:13 +0530  
21/Oct/2015:12:28:13 +0530  
21/Oct/2015:12:28:13 +0530  
21/Oct/2015:12:28:13 +0530  
21/Oct/2015:12:28:13 +0530  
21/Oct/2015:12:28:13 +0530

And this is my output:

Logstash startup completed  
{  
"message" =\> "21/Oct/2015:12:28:13 +0530\r",  
"@version" =\> "1",  
"@timestamp" =\> "2015-10-21T06:58:13.000Z",  
"host" =\> "7LH4ZR1",  
"path" =\> "C:\Users\eagasur\logs1.log",  
"mytimestamp" =\> "21/Oct/2015:12:28:13 +0530"  
}  
{  
"message" =\> "21/Oct/2015:12:28:13 +0530\r",  
"@version" =\> "1",  
"@timestamp" =\> "2015-10-21T06:58:13.000Z",  
"host" =\> "7LH4ZR1",  
"path" =\> "C:\Users\eagasur\logs1.log",  
"mytimestamp" =\> "21/Oct/2015:12:28:13 +0530"  
}

As logstash generates its own timestamp in the field @timestamp. But i have to use mytimestamp of the old logfile for plotting the graph in Kibana so i am trying to replace the @timestamp with mytimestamp. But its not working.  
I have used the same procedure as discussed in the link:

> [@Get the right timestamp for old log files](https://discuss.elastic.co/t/get-the-right-timestamp-for-old-log-files/24943/56):
>
> input { syslog { port =\> 5514 codec =\> "json" } file { path =\> "/var/externallogs\_maven/data" type =\> "nexus-log" start\_position =\> "beginning" } } filter { grok { type =\> "nexus-log" match =\> ["message", "\b\w+\b\s/nexus/content/repositories/(?\<repositories\>[^/]+)", "message", "(?\<mytimestamp\>%{MONTHDAY}/%{MONTH}/%{YEAR}:%{HOUR}:%{MINUTE}:%{SECOND} %{ISO8601\_TIMEZONE})" ] } date{ match =\> ["mytimestamp", "dd/MMM/YYY…

---

_[View the full topic](https://discuss.elastic.co/t/get-the-correct-timestamp-from-the-log-file/32633)._
