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


(Dimitry Khan) #1

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


(Magnus B├Ąck) #2

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


(Dimitry Khan) #3

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));"
}


(system) #4

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