# Replace @timestamp or add new field with time from log file

**URL:** <https://discuss.elastic.co/t/replace-timestamp-or-add-new-field-with-time-from-log-file/211007>\
**Category:** Logstash\
**Created:** [December 8, 2019, 12:47pm UTC](https://discuss.elastic.co/t/replace-timestamp-or-add-new-field-with-time-from-log-file/211007 "2019-12-08T12:47:29Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![pashang](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@pashang](https://discuss.elastic.co/u/pashang)\
**Post date:** [December 9, 2019, 6:27am UTC](https://discuss.elastic.co/t/replace-timestamp-or-add-new-field-with-time-from-log-file/211007/4 "2019-12-09T06:27:33Z")

</div>

I found solution from below link:

[https://discuss.elastic.co/t/logstash-cannot-assign-correct-date-to-log-timestamp/89249/7?u=pashang](https://discuss.elastic.co/t/logstash-cannot-assign-correct-date-to-log-timestamp/89249/7)

and I used below filter:

> filter {  
> grok { match =\> {"message" =\> "(?[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3})"} }  
> ruby { code =\> 'event.set("currentDate", Time.now.strftime("%Y.%m.%d"))' }  
> ruby { code =\> 'event.set("logTimestamp", event.get("currentDate") + " " + event.get("logTime"))' }  
> date { match =\> ["logTimestamp", "YYYY.MM.dd HH:mm:ss.SSS"] }  
> }

thanks every one 🙂

---

_[View the full topic](https://discuss.elastic.co/t/replace-timestamp-or-add-new-field-with-time-from-log-file/211007)._
