# Generating timestamp by concatenating date from filename and time from log events

**URL:** https://discuss.elastic.co/t/generating-timestamp-by-concatenating-date-from-filename-and-time-from-log-events/70196
**Category:** Logstash
**Created:** [December 29, 2016, 9:16am UTC](https://discuss.elastic.co/t/generating-timestamp-by-concatenating-date-from-filename-and-time-from-log-events/70196 "2016-12-29T09:16:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aviral\_srivastava](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviral_srivastava/32/98018_2.png) [@aviral\_srivastava](https://discuss.elastic.co/u/aviral_srivastava)
#### Post date: [December 29, 2016, 9:16am UTC](https://discuss.elastic.co/t/generating-timestamp-by-concatenating-date-from-filename-and-time-from-log-events/70196/1 "2016-12-29T09:16:29Z")

</div>

Hi,

I have a log file as follows:-  
Loading jar:file:/D:/smart/ProgramFiles/liferay-portal-6.0.5/tomcat-6.0.26/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties  
Loading jar:file:/D:/smart/ProgramFiles/liferay-portal-6.0.5/tomcat-6.0.26/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties  
Loading file:/D:/smart/ProgramFiles/liferay-portal-6.0.5/tomcat-6.0.26/webapps/ROOT/WEB-INF/classes/portal-ext.properties  
18:39:48,986 INFO [DialectDetector:69] Determining dialect for Oracle 11  
18:39:49,267 INFO [DialectDetector:49] Using dialect org.hibernate.dialect.Oracle10gDialect  
18:39:59,149 INFO [PortalImpl:277] Global lib directory /D:/smart/ProgramFiles/liferay-portal-6.0.5/tomcat-6.0.26/lib/ext/  
18:39:59,163 INFO [PortalImpl:297] Portal lib directory

Atmost all log events have starting format as HH:mm:ss,SSS. The log file names are as follows:-  
stdout\_20161220  
stdout\_20161026

I need to take the date from file name and time from log events and put in field timestamp. How is it possible??

---

<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: [December 31, 2016, 1:08pm UTC](https://discuss.elastic.co/t/generating-timestamp-by-concatenating-date-from-filename-and-time-from-log-events/70196/2 "2016-12-31T13:08:21Z")

</div>

The file path should be in the `path` field so you can use a grok filter to extract the date. Use another grok filter to extract the timestamp (and other fields) from each message and use a mutate filter to combine the date and the time into a single field. Finally use a date filter to parse that timestamp.

---

<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: [January 28, 2017, 1:08pm UTC](https://discuss.elastic.co/t/generating-timestamp-by-concatenating-date-from-filename-and-time-from-log-events/70196/3 "2017-01-28T13:08:39Z")

</div>

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