# Can I read input file's metadata (file creation time) through logstash?

**URL:** https://discuss.elastic.co/t/can-i-read-input-files-metadata-file-creation-time-through-logstash/118707
**Category:** Logstash
**Created:** [February 6, 2018, 7:43pm UTC](https://discuss.elastic.co/t/can-i-read-input-files-metadata-file-creation-time-through-logstash/118707 "2018-02-06T19:43:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Dimitry\_Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dimitry_khan/32/47127_2.png) [@Dimitry\_Khan](https://discuss.elastic.co/u/Dimitry_Khan)
#### Post date: [February 6, 2018, 7:43pm UTC](https://discuss.elastic.co/t/can-i-read-input-files-metadata-file-creation-time-through-logstash/118707/1 "2018-02-06T19:43:47Z")

</div>

Hi, can logstash read the metadata of the input file; say, the file creation time?

---

<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: [February 6, 2018, 9:39pm UTC](https://discuss.elastic.co/t/can-i-read-input-files-metadata-file-creation-time-through-logstash/118707/2 "2018-02-06T21:39:54Z")

</div>

Yes, if you use a ruby filter. The file input itself won't adorn events with input file metadata.

---

<div class="post-metadata">

### Author: ![Dimitry\_Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dimitry_khan/32/47127_2.png) [@Dimitry\_Khan](https://discuss.elastic.co/u/Dimitry_Khan)
#### Post date: [February 7, 2018, 12:00pm UTC](https://discuss.elastic.co/t/can-i-read-input-files-metadata-file-creation-time-through-logstash/118707/3 "2018-02-07T12:00:59Z")

</div>

Thanks @magnusbaeck. Solved now. Just to help others I am putting the code snippet

> ruby{  
> code =\> "file = event.get('path');  
> event.set('filename',file.split('/').last);  
> event.set('job\_datetime', File.ctime(file));"  
> }

---

<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: [March 7, 2018, 12:01pm UTC](https://discuss.elastic.co/t/can-i-read-input-files-metadata-file-creation-time-through-logstash/118707/4 "2018-03-07T12:01:04Z")

</div>

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